Select to view content in your preferred language

Get IExtensionManager

2418
2
04-19-2010 02:23 PM
RiverTaig1
Deactivated User
I'm trying to figure out how to get a refrence to IExtensionManager without using IApplication. This is an Engine application that I am developing, and IApplication isn't available (the typical sample has you casting from IApplication like so)

Dim pExtMgr As IExtensionManager
Dim pExt As IExtension
Set pExtMgr = Application


I tried to simply co-create the ExtensionManager like this:

IExtensionManager xMan = (IExtensionManager) new ESRI.ArcGIS.esriSystem.ExtensionManagerClass();

but it failed, "Unable to cast object of type 'System.__ComObject' to type 'ESRI.ArcGIS.esriSystem.ExtensionManagerClass'"

So how do you do this?

Thanks in advance.
0 Kudos
2 Replies
AntJ
by
Emerging Contributor
You can try with

IExtensionManagerAdmin pExAdmin = new ExtensionMangerClass();

IExtesnionManager pExtManager = (IExtensionManagerAdmin)pExAdmin;
0 Kudos
nicogis
MVP Frequent Contributor
ExtensionManagerClass is a singleton class see http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/interacting_with_single...
If you have this error is because you yet have a instance ExtensionManagerClass  that could be RCW generic System.__ComObject (in your case is so) so you cannot cast 'System.__ComObject'  to ExtensionManagerClass and ExtensionManagerClass  is a singleton.
you can resolve with

Type t = Type.GetTypeFromProgID("...");
System.Object obj = Activator.CreateInstance(t);
0 Kudos