AcrMap Application Extension AddIn and IExtensionConfig

2159
3
03-04-2012 11:47 PM
SandyReuther
New Contributor II
Hey there,

I wrote a little AddIn containing an Application Extension for ArcMap. Everything works fine but I'm not able to react when the user turns off the extension in the extension dialog. In former versions this worked with the IExtensionConfig interface, but the ArcMap extension as AddIn component doesn't listen to the IExtensionConfig.State, for whatever reason. And I don't find any example code in the whole wide WWW.

Does anybody have any idea? I would be too glad.

Many thanks...
Sandy
0 Kudos
3 Replies
EdgarBejarano
Occasional Contributor
Hi,

If you are going the Add-In route instead of developing a DLL custom component, mimick what is being done in the SelectionExtension.cs of the Custom Selection Extension developer (Add-In) developer sample.  In the Custom Selection Extension, the SelectionTargetComboBox essentially reacts to the end-user enabling and disabling the Add-In extension in the Extension dialog of ArcMap.

Place breakpoints in OnSetState and OnGetState, which are made available by the same ESRI.ArcGIS.Desktop.AddIns.Extension class which makes OnStartup available, in order to see how those 2 methods are being fired every time and end-user checks and unchecks the add-in extension in the Extension dialog.

Custom selection extension
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Custom_selection...

Also:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Extension_Members/001v00...
0 Kudos
SandyReuther
New Contributor II
Thank you very much, Edgar, that helped a lot. I am now able to prevent special users from disabling my extension. The only thing still not working is the refresh of the extension manager window, so the extension seems to be disabled althoug it is not. But that is not a major problem for me.

All the best...
Sandy
0 Kudos
EdgarBejarano
Occasional Contributor
Oh, it sounds like you have logic that determines the current user (username) so that you can prevent them from turning on or off the extension.  You can of course develop the Extension Add-In such that it does display in the Extension dialog, therefore always being enabled.  It is the showInExtensionDialog property in the config.xml file in the Add-In project, but this would apply to all users:

<ArcMap>
      <Extensions>
        <Extension id="ESRI_ArcMapAddin1_Extension1" class="Extension1" showInExtensionDialog="false" />
      </Extensions>
...
...
...
0 Kudos