Hexagon Geospatial
MENU

GeoMedia

Search for an answer, post a question, or answer other users' questions in our GeoMedia support discussions. This discussion board is a great way to collaborate with industry peers around the world. It is intended for discussion and support of the GeoMedia Desktop and Add-on applications.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Contributor
Posts: 30
Registered: ‎02-05-2018
Accepted Solution

Getting error while closing document in Geomedia Desktop

[ Edited ]

Dear Team ,

 

As we are working with Geomedia Application, We are opening the Geomedia Application using the Geomedia objects. While closing the document we are getting the error as shown in attachment.

Application_Error.jpg

 

Following is the code : -

 

 

 GeoMedia.Application GeoApp = null;

            GeoMedia.Document objDoc = null;

            GeoMedia.Windows objWin = null;

            GeoMedia.MapWindow objMap = null;

            PPipe.SpatialIntersectionPipe objSpatIntPipe = null;

            PView.LegendEntries objLEs = null;

            PView.LegendEntry objLE = null;

 

            string strProgId = "GeoMedia.Application";

 

            try

            {

                GeoApp = (GeoMedia.Application)System.Runtime.InteropServices.Marshal.GetActiveObject(strProgId);

                GeoApp.Visible = false;

            }

            catch

            {

                GeoApp = (GeoMedia.Application)Activator.CreateInstance(Type.GetTypeFromProgID("Geomedia.Application"));

                GeoApp.Visible = false;

            }

 

            objWin = (GeoMedia.Windows)GeoApp.Windows;

            if (objWin.Count > 0)

            {

                objDoc = (GeoMedia.Document)GeoApp.Document;

                objDoc.Close(null, null);

            }

 

            objDoc = (GeoMedia.Document)GeoApp.New(null, null, true);

            objMap = (GeoMedia.MapWindow)GeoApp.ActiveWindow;

            objMap.WindowState = (int)GeoMedia.WindowConstants.gmwMaximize;

            GeoApp.Visible = false;

 

            objMap.Close();

            objDoc.Close();

Getting the error at the end line .(

objDoc.Close();

)

 

Thanks

 

Technical Evangelist
Posts: 531
Registered: ‎09-11-2015

Re: Getting error while closing document in Geomedia Desktop

Hi sivaram,

 

please also note the product version you are using, since they may behave different. Especially for problems like this, GeoMedia 16.5 is not so sensitive for releasing COM object as the previous versions used to be. But still this may be the case. You should release any COM object which you don't need anymore. So in this case, I suggest you to try changes like this:

 

            objWin = (GeoMedia.Windows)GeoApp.Windows;
            if (objWin.Count > 0)
            {
                objDoc = (GeoMedia.Document)GeoApp.Document;
                objDoc.Close(null, null);
                Marshal.ReleaseComObject(objDoc);
            }
            Marshal.ReleaseComObject(objWin);
 
            objDoc = (GeoMedia.Document)GeoApp.New(null, null, true);
            objMap = (GeoMedia.MapWindow)GeoApp.ActiveWindow;
            objMap.WindowState = (int)GeoMedia.WindowConstants.gmwMaximize;
            GeoApp.Visible = false;
 
            objMap.Close();
            Marshal.ReleaseComObject(objMap);
            objDoc.Close();
            Marshal.ReleaseComObject(objDoc);

HTH,

 

Pavel

Contributor
Posts: 30
Registered: ‎02-05-2018

Re: Getting error while closing document in Geomedia Desktop

Thanks 

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.