We're attempting to interact with an application running on a Windows XP box that provides a COM interface. When the application, which is NOT running as a service, is running as the same Windows user as our test code we're able to instantiate the COM interface and make calls against it without any issues. We're using a simple instantiation:
using ServerLib;
...
ServerLib.ServerObject server = new ServerObject();
However, when we log into the same machine as a different user, and thus the server and application are running under different process spaces, and try to run the same code we get an error that reads:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: Retrieving the COM class factory for component with CLSID {BE8BD673-1442-449F-B56D-A7CC00DA1B0E} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
An entry in the System Event Viewer provides a clue:
The server {BE8BD673-1442-449F-B56D-A7CC00DA1B0E} did not register with DCOM within the required timeout.
The Windows Event log entries also provide some clues, but no answers:
A new process has been created:
New Process ID: 3168
Image File Name: C:\BIN\server.exe
Creator Process ID: 3348
User Name: USERNAME
Domain: DOMAIN
Logon ID: (0x0,0x3E7)
A process was assigned a primary token.
Assigning Process Information:
Process ID: 3348
Image File Name: C:\WINDOWS\system32\winlogon.exe
User Name: USERNAME
Domain: DOMAIN
Logon ID: (0x0,0x3E7)
New Process Information:
Process ID: 3168
Image File Name: C:\BIN\server.exe
User Name: CallingUser
Domain: DOMAIN
Logon ID: (0x0,0x217579E)
A process has exited:
Process ID: 3168
Image File Name: C:\BIN\server.exe
User Name: CallingUser
Domain: DOMAIN
Logon ID: (0x0,0x217579E)
We've also tried some alternative instantiation techniques, such as this one to try and attach to the existing process:
ServerLib.ServerObject foo = (ServerLib.ServerObject)System.Runtime.InteropServices.Marshal.GetActiveObject("Server.ServerObject");
This gets the following error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
We suspect that the issue revolves around the fact that our test code is running under a different login than the code hosting the COM interface. What we don't know is how to set up the configuration to allow us to make this work. The server hosting the COM interface is a singleton and a copy cannot be started up to handle COM requests by our client software.
What steps are necessary to get a client app on the same machine, but under a different process space to instantiate a COM interface and call methods in an .exe file host?
User contributions licensed under CC BY-SA 3.0