I need your advice for the following C# code:
EgarDDSEnt.IIVDDSEnt dds = null; // This line executes fine.
dds = new IVDDSEnt(); // This line fails with an exception ...
dds.Connect("username", "password"); // ... which makes this line fail too.
Here are the symptoms:
Windows Server 2008 R1:
- Code fails when executed from a Windows service app.
- Code works 100% when executed from a console app.
Windows 7:
- Code works 100% when executed from a Windows service app.
- Code works 100% when executed from a console app.
The class IVDDSEnt() is a COM object that is installe开发者_JAVA技巧d you install the "ivolatility SDK".
Update:
- When I execute "System.IO.Directory.GetCurrentDirectory()" from the console application, it returns "D:\MyDevDirectory\"
- When I execute "System.IO.Directory.GetCurrentDirectory()" from the service application, it returns "C:\windows\system32\".
- The application is actually the same binary for both service and console (its a hybrid app that can run in console mode, or install itself as a service if you pass "-service" to it on the command line).
Update:
Added try/catch, and "e.GetBaseException" (defined as "Returns the exception which is the root cause of one or more subsequent exceptions"):
System.Runtime.InteropServices.COMException (0x80080005): Retrieving
the COM class factory for component with CLSID
{FA944FE7-AEB8-4B5B-8315-11D19B1F6264} failed due to the following error:
80080005 Server execution failed (Exception from HRESULT:
0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
at PhiDataOnSchedule.ConsoleApplication.MyMain(Boolean dummyRun)
Update:
Still can't fix the problem - the easiest way might be to just upgrade from Windows Server 2008 R1 to Windows Server 2008 R2 (if it works on Win7, and Windows Server 2008 R2 has a Win7 core, perhaps it'll work around the underlying issue somehow?).
That's probably a rights problem. Check under which service account the service runs and its rights. Then either change the service account or expand its rights.
CO_E_SERVER_EXEC_FAILURE
is "Server execution failed".
This would indicate the component should be out of process, but the COM runtime could not start the executable (or, maybe, load the dll into a host process).
Looking for activity against the file containing the component with Process Monitor might give you a clue (it could be permissions: Process Monitor could confirm this).
Perhaps I have to specify an account to run the service under?
For a complete example of how to code this up, see:
http://www.codeproject.com/KB/WPF/LtoE.aspx?artkw=LINQ%20to%20WCF#ShowIt
Search for the text: "When the installer is run, it will allow you to enter the service login credentials to run under, using the following dialog box":
精彩评论