Select to view content in your preferred language

How to cast in opening an ESRI.ArcGIS.Location.RouteMeasureLineLocationClass?

616
2
Jump to solution
09-24-2013 11:43 AM
ShaningYu
Honored Contributor
I want to open an ESRI.ArcGIS.Location.RouteMeasureLineClass from a GeoDB.  From
http://resources.esri.com/help/9.3/arcgisengine/arcobjects/esriLocation/Location_overview.htm
I got Open LocalLocatorWorkspace.  Then I used the code below: 
        public ESRI.ArcGIS.Location.RouteMeasureLineLocationClass GetRouteMeasureClass(ESRI.ArcGIS.Location.IDatabaseLocatorWorkspace ws, string fName)
        {
            IFeatureWorkspace fWs = (IFeatureWorkspace)ws;
            return (ESRI.ArcGIS.Location.RouteMeasureLineLocationClass)(fWs.OpenFeatureClass(fName));
        }
But got error:  Cannot implicitly convert type 'ESRI.ArcGIS.Geodatabase.IFeatureClass' to 'ESRI.ArcGIS.Location.RouteMeasureLineLocationClass'. An explicit conversion exists (are you missing a cast?)
How can a proper casting be applied?  Thanks.
0 Kudos
1 Solution

Accepted Solutions
ShaningYu
Honored Contributor
Through intensive search, found that the ESRI.ArcGIS.Location.RouteMeasureLineLocationClass can't be opened directly.  Since I have adapted an alternative approach to target my goal, this thread is to be closed.

View solution in original post

0 Kudos
2 Replies
ShaningYu
Honored Contributor
Revised the code as:
        public ESRI.ArcGIS.Location.RouteMeasureLineLocationClass GetRouteMeasureClass(ESRI.ArcGIS.Location.IDatabaseLocatorWorkspace ws, string fName) {
            IFeatureWorkspace fWs = (IFeatureWorkspace)ws;
            ESRI.ArcGIS.Location.RouteMeasureLineLocationClass fcLoc = (ESRI.ArcGIS.Location.RouteMeasureLineLocationClass)(fWs.OpenFeatureClass(fName));
            return (ESRI.ArcGIS.Location.RouteMeasureLineLocationClass)(fWs.OpenFeatureClass(fName));
        }
Got The runtime error at the Line:  Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Location.IRouteLocation'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{354B908D-3BBA-11D4-9FCC-00C04F6BDF06}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
0 Kudos
ShaningYu
Honored Contributor
Through intensive search, found that the ESRI.ArcGIS.Location.RouteMeasureLineLocationClass can't be opened directly.  Since I have adapted an alternative approach to target my goal, this thread is to be closed.
0 Kudos