I am converting an automation utility from ArcMap 9.3 to 10.2.2. I changed some references and added binding to the Desktop license. In 9.3 I was able to connect to an existing instance of ArcMap using the following statement:
AppROT rot = new AppROTClass(); // WORKS in 9.3, THROWS EXCEPTION in 10.2.2
In 10.2.2 this throws a COM exception about the class not existing. However, in 10.2.2 when I create the instance of ArcMap in my code, the AppROT works.
IDocument doc = (IDocument) new ESRI.ArcGIS.ArcMapUI.MxDocumentClass();
AppROT rot = new AppROTClass(); // WORKS in 10.2.2
Does anyone know why I cannot connect to an existing instance of ArcMap in 10.2.2? Thanks. Mary Sage
Now, the above code does not work in 10.2.2.
I'm getting the exception:
System.Runtime.InteropServices.COMException (0x80040111): Retrieving the COM class factory for component with CLSID {FABC30FB-D273-11D2-9F36-00C04F6BC61A} failed due to the following error: 80040111.
Did I mention I'm trying to execute the sample: DesktopAutomationCS2010? I added the bind to the Desktop for the license.
Thanks for any help.
We currently encounter similar error message on 10.2.2 Desktop, however the scenario might be a little bit different:
new AppROTClass() throws the same exception as you get if and only if there's already an instance of AppRot.exe running on the system (under the same user account, with elevated = yes). The programm calling new AppROTClass() is being executed as a windows task scheduler triggered executable.
The second time the task is triggered, the exception hits us (while the first time works and instanciates AppROT.exe). If I kill the AppROT.exe process before the task is triggered the second time, things work well, too.
Of course, the binding is made properly. And creating a new AppROTClass should not need any other licensing, except for the binding to Desktop.
I'm a bit worried about the AppROT.exe running elevated. What else could be involved? The scheduler task is being executed with a user having local administrator privileges (and that might explain the elevation).
Maybe this additional info helps to track this problem down?
Have you found a work around for the problem using AppRot with 10.2.2?
Hi Michael. No, not yet and we have not taken further steps in resolving this (requirements changed and we did not need to find a proper solution). Still, for future projects or implementations, it would obviously be good if there'd be a solution to this.
I wouldn't vouch for it, but yes. It looks like broken behaviour or wrong documentation or something along these lines. Of course, I might also be doing something wrong after all.
Andry,
I think its a security issue that started with vista, see AppROT and Windows Vista
For me, the following only works if both arcmap and the console app are running at the same permissions (both elevated or both not, but not a mix). If they're different, I get the error.
//find Arcmap and change title IApplication app = null; IAppROT appRot = new AppROTClass(); for (int i = 0; i < appRot.Count; i++) { if (appRot.get_Item(i) is IMxApplication) { app = appRot.get_Item(i); app.Caption = "Connected"; } } if (appRot == null) { MessageBox.Show("unable to find arcmap"); }
Maybe try an application manifest?
Sean