I'm writing an add-in for ArcMap 10.0 using VB.Net and I'm running into an Invalid Cast Exception.
The error message is:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.PublisherControls.ARLayer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{33DF9650-35B7-42F8-A7C9-9F8A1B53AA80}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
The line that I believe is generating the error is:
I'm fairly certain that LayerNum is accurate and this code works in a stand-alone application that performs the same function, so I'm not sure what I'm doing incorrectly. The next thing I was going to try was something like:
But I wanted to see if I could get some opinions and ideas before I tried it.
Thanks!
The error message is:
Quote:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.PublisherControls.ARLayer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{33DF9650-35B7-42F8-A7C9-9F8A1B53AA80}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Code:
Dim SearchLayer as ESRI.ArcGIS.PublisherControls.ARLayer = My.ArcMap.Document.FocusMap.Layer(LayerNum)
Code:
Dim SearchLayer As ESRI.ArcGIS.PublisherControls.ARLayer
SearchLayer = CType(My.ArcMap.Document.FocusMap.Layer(LayerNum), ESRI.ArcGIS.PublisherControls.ARLayer)
Thanks!