All:
I'm having trouble translating some VBA code into C #.
We have a third-party application that acts as a local COM server.
In VBA code, we use GetObject () to get a reference to an existing object
eg.
Set appHandle = GetObject("", ProgId)
it works great.
I added a link to a third-party application in our C # code and used Marshal.GetActiveObject () to try to get a link to the executable instance.
eg.
var appModel = (IAppCoModel)Marshal.GetActiveObject(ProgId);
but I keep getting MK_E_UNAVAILABLE .
Creating a new object works fine in C # code
eg.
var appModel = new AppCoModel()
this launches a third-party application and allows me to communicate with it. It only captures a reference to an executable instance that fails.
What i tried
Different security contexts
VS works in administrator mode, a third-party application does not. I tried to launch our C # application from the command line (non-admin). Still not working.
Check the contents of the ROT
(suggested by Marshal.GetActiveObject () throws MK_E_UNAVAILABLE exception in C # )
A third-party application does not appear in it. I do not know enough COM to be sure that this is necessary.
Checked all registry entries
Look good (as far as I can see) and they are good enough to create and instantiate a third-party application and for VBA to find it. Anything specific I should check here?
Any suggestions that people can make will be appreciated.
AlanT source share