C# WinService starts in win7 but not in win2088
-
I have developed a C# .Net 3.5 Windows service application that works perfectly fine when I run it in Visual Studio, however when I try to install it on a Windows 2008 R2 64-bit server, it fails to start. The only error that is shown is:
A system error has occurred. System error 1067 has occurred. The process terminated unexpectedly.
No more information, nothing at all in the event log. There is no Com+ or similar, just a plain service. (Also tried to remove all logic from the service with no luck). I've tried to compile all parts with "AnyCPU" and 64-bit without luck. I've tried both the 32-bit and 64-bit installutil. If I copy the entire folder to a Win7 machine (64bit) and install it in the exact same way, it works like it should. Any ideas at all on how to resolve this? I'm pretty much out of ideas and without any logs whatsoever, it's hard to find out what it could be.
-
I have developed a C# .Net 3.5 Windows service application that works perfectly fine when I run it in Visual Studio, however when I try to install it on a Windows 2008 R2 64-bit server, it fails to start. The only error that is shown is:
A system error has occurred. System error 1067 has occurred. The process terminated unexpectedly.
No more information, nothing at all in the event log. There is no Com+ or similar, just a plain service. (Also tried to remove all logic from the service with no luck). I've tried to compile all parts with "AnyCPU" and 64-bit without luck. I've tried both the 32-bit and 64-bit installutil. If I copy the entire folder to a Win7 machine (64bit) and install it in the exact same way, it works like it should. Any ideas at all on how to resolve this? I'm pretty much out of ideas and without any logs whatsoever, it's hard to find out what it could be.
Add some logging to your program. You could use a common logging framework like log4net. Good places to start with are the constructor of your service and the OnStart method. You'll see then how far the initialization runs on that machine, and can get an idea about what went wrong.
-
Add some logging to your program. You could use a common logging framework like log4net. Good places to start with are the constructor of your service and the OnStart method. You'll see then how far the initialization runs on that machine, and can get an idea about what went wrong.
We are using logging (log4net) but nothing was logged. But I added some logging points and found out that it is the dynamic loading of an external dll that fails. (Activator.CreateInstance)
ERROR!! Assemblyladdningsfel! Exception has been thrown by the target of an invocation.
ERROR!! Exception has been thrown by the target of an invocation.ERROR!! The type initializer for 'MyExternalDll' threw an exception.Don't know why yet, but probably due to some stupid 2008 security control.
-
We are using logging (log4net) but nothing was logged. But I added some logging points and found out that it is the dynamic loading of an external dll that fails. (Activator.CreateInstance)
ERROR!! Assemblyladdningsfel! Exception has been thrown by the target of an invocation.
ERROR!! Exception has been thrown by the target of an invocation.ERROR!! The type initializer for 'MyExternalDll' threw an exception.Don't know why yet, but probably due to some stupid 2008 security control.
No, surely not "MyExternalDll", but the constructor of a class therein. Look again at the original message!
-
I have developed a C# .Net 3.5 Windows service application that works perfectly fine when I run it in Visual Studio, however when I try to install it on a Windows 2008 R2 64-bit server, it fails to start. The only error that is shown is:
A system error has occurred. System error 1067 has occurred. The process terminated unexpectedly.
No more information, nothing at all in the event log. There is no Com+ or similar, just a plain service. (Also tried to remove all logic from the service with no luck). I've tried to compile all parts with "AnyCPU" and 64-bit without luck. I've tried both the 32-bit and 64-bit installutil. If I copy the entire folder to a Win7 machine (64bit) and install it in the exact same way, it works like it should. Any ideas at all on how to resolve this? I'm pretty much out of ideas and without any logs whatsoever, it's hard to find out what it could be.
-
I have developed a C# .Net 3.5 Windows service application that works perfectly fine when I run it in Visual Studio, however when I try to install it on a Windows 2008 R2 64-bit server, it fails to start. The only error that is shown is:
A system error has occurred. System error 1067 has occurred. The process terminated unexpectedly.
No more information, nothing at all in the event log. There is no Com+ or similar, just a plain service. (Also tried to remove all logic from the service with no luck). I've tried to compile all parts with "AnyCPU" and 64-bit without luck. I've tried both the 32-bit and 64-bit installutil. If I copy the entire folder to a Win7 machine (64bit) and install it in the exact same way, it works like it should. Any ideas at all on how to resolve this? I'm pretty much out of ideas and without any logs whatsoever, it's hard to find out what it could be.
Daniel Jansson wrote:
If I copy the entire folder to a Win7 machine (64bit) and install it in the exact same way, it works like it should.
Incorrect process. 1. Install it on the Win 7 machine 2. Install it on Win 2008 3. Delete the files from Win 7 4. Copy the files as installed from Win 2008 to Win 7. 5. See if it runs. If it doesn't compare files.
Daniel Jansson wrote:
Any ideas at all on how to resolve this?
Presuming the install works then it means it is an environment problem. First change the user that the service runs under to you. Try to run it. If that doesn't work then open permissions up completely on the install dir. If that doesn't fix it then restore then and continue. Next step is to determine if it is a start up problem or a code problem. You might be able to determine this by adding a log line as the very first line of the Startup (Service method itself). If that gets into the log then you know that some other process is falling. You can debut that by putting a try/catch in Startup, which you should have anyways and log it. This doesn't work if you start threads and you will need to add more logging for exceptions in threads (which you should also be doing any ways.) If the first log line doesn't show up then it becomes more difficult because it means that the service class is attempting to pull in a dll and initialization for that fails. Resolving that is done by creating a proxy in the Service which uses dynamic loading of everything else. Basically clone all the real functionality in the Service class, remove the functionality from the service class, then use dynamic loading to load and execute the second class with appropriate exception handling and logging for that. Of course the above assumes that logging itself isn't the problem.