<?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 Calling an ArcMap extension(add-in) method from another ArcMap extension(add-in) in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/calling-an-arcmap-extension-add-in-method-from/m-p/1370459#M20631</link>
    <description>&lt;P&gt;I have a third-party ArcMap extension (codes not available) is SomeException.&lt;BR /&gt;This extension implements the IExtension, IExtensionConfig, IPersistVariant and ISomeInterface interfaces&lt;BR /&gt;I'm calling SomeException methods from another ArcMap extension.&lt;/P&gt;&lt;P&gt;On a Windows 10 machine running ArcGis 10.5, the ISomeInterface methods are available from my extension and (SomeException is ISomeInterface) = true.&lt;BR /&gt;On a Windows 8 machine running ArcGis 10.2, ISomeInterface methods are not available from my extension and (SomeException is ISomeInterface) = false.&lt;BR /&gt;The IExtension, IExtensionConfig, IPersistVariant interfaces are always available.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What could be the problem?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Perhaps ISomeInterface is not a COM interface.&lt;BR /&gt;I don't know whether the SomeException extension class has the ComVisible(true) attribute or not.&lt;/P&gt;&lt;P&gt;Is there any way to make all interfaces of the SomeException extension available at the OS level?&lt;/P&gt;&lt;P&gt;On a Windows 8 machine running ArcGis 10.2, the ISomeInterface interface can be accessed by declaring the COM extension object as dynamic.&lt;BR /&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var extClass = new UIDClass();
extClass.Value = "{XXXXX-XXX...}";
dynamic someExt = _application.FindExtensionByCLSID( extClass);

someExt.SomeMethod(); //method of ISomeInterface&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If SomeMethod has no parameters, then the call occurs correctly.&lt;BR /&gt;If SomeMethod has a class among its parameters, an error occurs.&lt;BR /&gt;For example, such a call to the method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  someExt.SomeMethod_2(someClass);  //method 2 of ISomeInterface&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is the following error:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; System.InvalidCastException: Failed to cast object type 'System.__ComObject' to type 'someClass'.    in System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   in System.Dynamic.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo&amp;amp; excepInfo, UInt32 argErr, String message)
   in CallSite.Target(Closure , CallSite , ComObject , JOB )
   in System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   in CallSite.Target(Closure , CallSite , Object , JOB )
   in System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;How can I call SomeMethod_2 correctly?&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jan 2024 14:32:59 GMT</pubDate>
    <dc:creator>vsevgu</dc:creator>
    <dc:date>2024-01-16T14:32:59Z</dc:date>
    <item>
      <title>Calling an ArcMap extension(add-in) method from another ArcMap extension(add-in)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/calling-an-arcmap-extension-add-in-method-from/m-p/1370459#M20631</link>
      <description>&lt;P&gt;I have a third-party ArcMap extension (codes not available) is SomeException.&lt;BR /&gt;This extension implements the IExtension, IExtensionConfig, IPersistVariant and ISomeInterface interfaces&lt;BR /&gt;I'm calling SomeException methods from another ArcMap extension.&lt;/P&gt;&lt;P&gt;On a Windows 10 machine running ArcGis 10.5, the ISomeInterface methods are available from my extension and (SomeException is ISomeInterface) = true.&lt;BR /&gt;On a Windows 8 machine running ArcGis 10.2, ISomeInterface methods are not available from my extension and (SomeException is ISomeInterface) = false.&lt;BR /&gt;The IExtension, IExtensionConfig, IPersistVariant interfaces are always available.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What could be the problem?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Perhaps ISomeInterface is not a COM interface.&lt;BR /&gt;I don't know whether the SomeException extension class has the ComVisible(true) attribute or not.&lt;/P&gt;&lt;P&gt;Is there any way to make all interfaces of the SomeException extension available at the OS level?&lt;/P&gt;&lt;P&gt;On a Windows 8 machine running ArcGis 10.2, the ISomeInterface interface can be accessed by declaring the COM extension object as dynamic.&lt;BR /&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var extClass = new UIDClass();
extClass.Value = "{XXXXX-XXX...}";
dynamic someExt = _application.FindExtensionByCLSID( extClass);

someExt.SomeMethod(); //method of ISomeInterface&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If SomeMethod has no parameters, then the call occurs correctly.&lt;BR /&gt;If SomeMethod has a class among its parameters, an error occurs.&lt;BR /&gt;For example, such a call to the method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  someExt.SomeMethod_2(someClass);  //method 2 of ISomeInterface&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is the following error:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; System.InvalidCastException: Failed to cast object type 'System.__ComObject' to type 'someClass'.    in System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   in System.Dynamic.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo&amp;amp; excepInfo, UInt32 argErr, String message)
   in CallSite.Target(Closure , CallSite , ComObject , JOB )
   in System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   in CallSite.Target(Closure , CallSite , Object , JOB )
   in System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;How can I call SomeMethod_2 correctly?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 14:32:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/calling-an-arcmap-extension-add-in-method-from/m-p/1370459#M20631</guid>
      <dc:creator>vsevgu</dc:creator>
      <dc:date>2024-01-16T14:32:59Z</dc:date>
    </item>
  </channel>
</rss>

