salbeke

COM Error when locating route events

Discussion created by salbeke on Apr 12, 2010
I am programming a custom tool using VB.NET in ArcGIS 9.3.1. With this tool I want to use a 'moving-window' approach to move along a route event and calculate some metrics. I have performed similar tasks using VBA, but, unfortunately, have now run into a snag that I can't seem to solve while porting the code over to .NET. Using the exact examples suggested by the ESRI website, I keep getting a COM exception when trying to set my IRouteLocator2 object. The error states: ,  "COM -2147483638 The data necessary to complete this operation is not yet available. (Exception form HResult 0x8000000A)". My code follows and is programmed as a UserForm instantiated by the OnClick of an ArcGIS BaseTool:

...some previous stuff
m_pMap = m_pMxDoc.FocusMap

            'get the route feature class, M-aware has been tested earlier
            Dim pLayer As ILayer
            Dim pFLayer As IFeatureLayer
            Dim pRouteFc As IFeatureClass

            pRouteFc = pFLayer.FeatureClass

            ''create a route locator object
            Dim pDS As IDataset = CType(pRouteFc, IDataset)
            Dim pName As IName = pDS.FullName
            Dim pRtLocName As IRouteLocatorName = New RouteMeasureLocatorNameClass()

            With pRtLocName
                .RouteFeatureClassName = pName 'same as combobox
                .RouteIDFieldName = cmbFID.SelectedText 'selected from RID combobox
                .RouteIDIsUnique = True
                .RouteMeasureUnit = esriUnits.esriMeters 'i am specifying meters as a requirement
                '.RouteWhereClause = ""
            End With

            pName = CType(pRtLocName, IName)

'//////////////////////////////////////////////
'the next line is where the exception gets thrown!!
            Dim pRtLoc As IRouteLocator2 = CType(pName.Open(), IRouteLocator2)

Outcomes