Message 1 of 2
Marshal.GetActiveObject("Inventor.Application") fails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We are facing strange issue when we are running Visual studio in non admin mode then its working perfect but same thing is not working in Admin mode. Can you please help us ?
Here is the code: /// <summary> /// Connects to a running instance of Inventor or /// Creates a new instance and connects to it. /// </summary> /// <returns>Instance of Inventor app</returns> private Inventor.Application Connect() { string InventorProgID = "Inventor.Application"; Inventor.Application inventorApp = null; // Try to get an active instance of Inventor try { inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject(InventorProgID) as Inventor.Application; //This throws Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING)) } catch { //(MK_E_UNAVAILABLE)) is expected when Inventor is not running in interactive mode. } // If Inventor is not running, create a new Inventor session if (null == inventorApp) { Type inventorAppType = Type.GetTypeFromProgID(InventorProgID); //This returns null, when process is Run As Administrator. Debug.Assert(inventorAppType != null, "inventorAppType is null."); if (null != inventorAppType) { inventorApp = Activator.CreateInstance(inventorAppType) as Inventor.Application; Debug.Assert(inventorApp != null, "inventorApp is null."); } } return inventorApp; }
This is what we observed in using process monitor.
[A] While running as Non-Admin User:
Process monitor shows successfull registry events as below.
[B] While running as Admin User:
Process monitor shows unsuccessfull registry events as below.