Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# WinService starts in win7 but not in win2088

C# WinService starts in win7 but not in win2088

Scheduled Pinned Locked Moved C#
csharpvisual-studiocomsysadminhelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Daniel Jansson
    wrote on last edited by
    #1

    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.

    B L J 3 Replies Last reply
    0
    • D Daniel Jansson

      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.

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      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.

      D 1 Reply Last reply
      0
      • B Bernhard Hiller

        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.

        D Offline
        D Offline
        Daniel Jansson
        wrote on last edited by
        #3

        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.

        B 1 Reply Last reply
        0
        • D Daniel Jansson

          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.

          B Offline
          B Offline
          Bernhard Hiller
          wrote on last edited by
          #4

          No, surely not "MyExternalDll", but the constructor of a class therein. Look again at the original message!

          1 Reply Last reply
          0
          • D Daniel Jansson

            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.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Depends on what your code is trying to do. There could be a security exception and an unhandled exception might stop the service. It is very difficult to guess without seeing your code.

            1 Reply Last reply
            0
            • D Daniel Jansson

              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.

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups