<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Casting Error in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241705#M6250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to cast from IFeatureClass to INetworkClass and I get the following error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Geodatabase.INetworkClass'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{EE2896B0-5ED8-11D2-AA8A-00C04FA37B82}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using VB.Net in Visual Studio 2010 and ArcObjects SDK 10.2 on X64 Windows 7.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is my sample code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

Sub Test ( ByRef pFeatClass as IFeatureClass)

Dim pnF&amp;nbsp; as INetworkClass 
pnF&amp;nbsp; = pFeatClass

End Sub
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this simple code, i am getting the above mentioned exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried, &lt;/SPAN&gt;&lt;STRONG&gt;CType,DirectCast&lt;/STRONG&gt;&lt;SPAN&gt; also with o&lt;/SPAN&gt;&lt;STRONG&gt;ption Strict Off&lt;/STRONG&gt;&lt;SPAN&gt;, but no use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is much appreciated on this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kiran.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Dec 2013 12:56:01 GMT</pubDate>
    <dc:creator>SanajyJadhav</dc:creator>
    <dc:date>2013-12-23T12:56:01Z</dc:date>
    <item>
      <title>Casting Error</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241705#M6250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to cast from IFeatureClass to INetworkClass and I get the following error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Geodatabase.INetworkClass'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{EE2896B0-5ED8-11D2-AA8A-00C04FA37B82}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using VB.Net in Visual Studio 2010 and ArcObjects SDK 10.2 on X64 Windows 7.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is my sample code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

Sub Test ( ByRef pFeatClass as IFeatureClass)

Dim pnF&amp;nbsp; as INetworkClass 
pnF&amp;nbsp; = pFeatClass

End Sub
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this simple code, i am getting the above mentioned exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried, &lt;/SPAN&gt;&lt;STRONG&gt;CType,DirectCast&lt;/STRONG&gt;&lt;SPAN&gt; also with o&lt;/SPAN&gt;&lt;STRONG&gt;ption Strict Off&lt;/STRONG&gt;&lt;SPAN&gt;, but no use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is much appreciated on this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kiran.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 12:56:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241705#M6250</guid>
      <dc:creator>SanajyJadhav</dc:creator>
      <dc:date>2013-12-23T12:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Casting Error</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241706#M6251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Checking the docs, I see that INetworkClass is a Subinterface of IFeatureClass. (at least in the Java docs).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What this means is, you don't need to cast it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only two implementing classes of the INetworkClass are:&amp;nbsp; FeatureClass and INetworkClassProxy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2013 14:02:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241706#M6251</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-12-23T14:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Casting Error</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241707#M6252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Leo for the reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I fixed the issue. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason for the failure was, the source IFeatureClass did not belong to the Geoemtric Network. It was a "NORMAL" feature class.&amp;nbsp; That's why, the cast was failing.When I used the feature class from the GN, it got casted to INetworkClass. So, my same code worked without any change.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kiran.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 08:23:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241707#M6252</guid>
      <dc:creator>SanajyJadhav</dc:creator>
      <dc:date>2013-12-24T08:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Casting Error</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241708#M6253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That is not what you posted originally.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your OP didn't mention you were using the GeometricNetwork.&amp;nbsp; You asked why casting between IFeatureClass and INetworkClass was giving you an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you look at the documentation for GeometricNetwork, you can see all the implemented interfaces for that class.&amp;nbsp; If you want to go from GeometricNetwork to a FeatureClass, you need IDataset.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 13:36:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241708#M6253</guid>
      <dc:creator>LeoDonahue</dc:creator>
      <dc:date>2013-12-24T13:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Casting Error</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241709#M6254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Leo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am sorry if there has been any misunderstanding, I never meant it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, I know I should have mentioned that I was using GemetricNetwork and it would had been more clearer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry once again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sanjay.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Dec 2013 05:15:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/casting-error/m-p/241709#M6254</guid>
      <dc:creator>SanajyJadhav</dc:creator>
      <dc:date>2013-12-25T05:15:31Z</dc:date>
    </item>
  </channel>
</rss>

