Set EventTable

470
1
Jump to solution
09-24-2013 07:48 AM
ShaningYu
Frequent Contributor
From http://forums.arcgis.com/threads/14202-Inserting-LR-Event-Features-with-VBA, where the code is in VBA:
  Dim pRouteEventSource As IRouteEventSource
  Set pRouteEventSource = pFLayer.FeatureClass
I tried to setup an EventTable like that:
            ESRI.ArcGIS.Location.IRouteEventSource pRouteEventSource = fc;  // fc - a defined FeatureClass
But I got compile error warning under fc: Can't explicitly convert IFeatureClass to IRouteEventSource.
The, I cast it like that
            ESRI.ArcGIS.Location.IRouteEventSource pRouteEventSource = (ESRI.ArcGIS.Location.IRouteEventSource)fc;
            ITable pTable = pRouteEventSource.EventTable;
The compile error was gone.  But then I got runtime error:  Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Location.IRouteEventSource'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{641755F0-B7DE-11D3-9F7C-00C04F6BDF06}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I hope someone can help me for the possible solution.  Thanks.
0 Kudos
1 Solution

Accepted Solutions
ShaningYu
Frequent Contributor
In stead of using IRouteEventSource, I used co-class: RouteEventSource and the compile error was gone.
        public string GetRouteMeasureClass(IWorkspace ws, string fName) {
            IFeatureWorkspace fWs = (IFeatureWorkspace)ws;
            IFeatureClass fClass = fWs.OpenFeatureClass(fName);
            ESRI.ArcGIS.Location.RouteEventSource rteEventSource;  
            rteEventSource = (ESRI.ArcGIS.Location.RouteEventSource)fClass;
            ...
        }
But another problem occurs.  In VS 2010 Object Browser: RouteEventSource is shown as an interface, which contains IDataset only.  Whilst in ESRI literature, it is a co-class.  There is something incorrect.  I have reported it another thread (http://forums.arcgis.com/threads/93431-Subclass-RouteEventSource).  I will close this one.

View solution in original post

0 Kudos
1 Reply
ShaningYu
Frequent Contributor
In stead of using IRouteEventSource, I used co-class: RouteEventSource and the compile error was gone.
        public string GetRouteMeasureClass(IWorkspace ws, string fName) {
            IFeatureWorkspace fWs = (IFeatureWorkspace)ws;
            IFeatureClass fClass = fWs.OpenFeatureClass(fName);
            ESRI.ArcGIS.Location.RouteEventSource rteEventSource;  
            rteEventSource = (ESRI.ArcGIS.Location.RouteEventSource)fClass;
            ...
        }
But another problem occurs.  In VS 2010 Object Browser: RouteEventSource is shown as an interface, which contains IDataset only.  Whilst in ESRI literature, it is a co-class.  There is something incorrect.  I have reported it another thread (http://forums.arcgis.com/threads/93431-Subclass-RouteEventSource).  I will close this one.
0 Kudos