<?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 Re: System.InvalidCastException when using PublisherControls.ARLayer in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9046#M226</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;[Edit]: I am making the changes you suggested, but we only have one mapping person and I will need to wait until he is available to test.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are correct; I'm not doing any threading with this add-in (that's not a bad idea, but I'll have to leave it for a later date).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What we're trying to do is create a search function that will search multiple layers and fields in those layers for user-entered text. I'm not as familiar with ArcObjects as I'd like to be (so I'm likely not doing this in the easiest of ways). I was using the ARLayer.QueryARFeatures method to search for text in the layer fields. I was doing it this way because I found some similar code on the forums and adapted it for our immediate needs. If there's an easier or better way to do this, please let me know.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Feb 2013 19:14:52 GMT</pubDate>
    <dc:creator>KennMurphy</dc:creator>
    <dc:date>2013-02-27T19:14:52Z</dc:date>
    <item>
      <title>System.InvalidCastException when using PublisherControls.ARLayer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9044#M224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm writing an add-in for ArcMap 10.0 using VB.Net and I'm running into an Invalid Cast Exception. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error message is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;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)).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The line that I believe is generating the error is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Dim SearchLayer as ESRI.ArcGIS.PublisherControls.ARLayer = My.ArcMap.Document.FocusMap.Layer(LayerNum)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Dim SearchLayer As ESRI.ArcGIS.PublisherControls.ARLayer
SearchLayer = CType(My.ArcMap.Document.FocusMap.Layer(LayerNum), ESRI.ArcGIS.PublisherControls.ARLayer)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I wanted to see if I could get some opinions and ideas before I tried it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:22:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9044#M224</guid>
      <dc:creator>KennMurphy</dc:creator>
      <dc:date>2021-12-10T20:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: System.InvalidCastException when using PublisherControls.ARLayer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9045#M225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;FocusMap.Layer returns ILayer.&amp;nbsp; I'd get the result as that type and then log the Name and other details before trying to cast it to the type of layer that you believe it should be.&amp;nbsp; That should help you debug the issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My assumption here is that all of this is occurring on the main thread of execution.&amp;nbsp; Please state if this assumption is incorrect.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 16:35:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9045#M225</guid>
      <dc:creator>RichardWatson</dc:creator>
      <dc:date>2013-02-27T16:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: System.InvalidCastException when using PublisherControls.ARLayer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9046#M226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;[Edit]: I am making the changes you suggested, but we only have one mapping person and I will need to wait until he is available to test.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are correct; I'm not doing any threading with this add-in (that's not a bad idea, but I'll have to leave it for a later date).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What we're trying to do is create a search function that will search multiple layers and fields in those layers for user-entered text. I'm not as familiar with ArcObjects as I'd like to be (so I'm likely not doing this in the easiest of ways). I was using the ARLayer.QueryARFeatures method to search for text in the layer fields. I was doing it this way because I found some similar code on the forums and adapted it for our immediate needs. If there's an easier or better way to do this, please let me know.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 19:14:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9046#M226</guid>
      <dc:creator>KennMurphy</dc:creator>
      <dc:date>2013-02-27T19:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: System.InvalidCastException when using PublisherControls.ARLayer</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9047#M227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm sorry it took so long to respond, but that didn't help. I've decided to try a different tack and will be trying to use the FindFeatures CoClass. Thanks for the help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Mar 2013 14:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/system-invalidcastexception-when-using/m-p/9047#M227</guid>
      <dc:creator>KennMurphy</dc:creator>
      <dc:date>2013-03-11T14:21:33Z</dc:date>
    </item>
  </channel>
</rss>

