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 installed 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?).
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”: