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 / C++ / MFC
  4. Windows Service: Strange problem (crashes)...

Windows Service: Strange problem (crashes)...

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabaseperformance
4 Posts 3 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.
  • F Offline
    F Offline
    FreeCastle
    wrote on last edited by
    #1

    Hi, with the help of MSDN I wrote my own little (pure) Windows Service, that doesn't do anything. I also implemented the ability to install/uninstall this service in the service database. My problem now is, that if I want to start that service from the system control in windows it crashes with a well known error message like this: "The instruction at 0xnnnnnnn referenced memory at 0xnnnnnnn. The memory could not be written." I then wrote a simple logging-function, which prints the status information about my service to a file. And when I look at this file it seems that all is correct. All things are initialized and so on. And I also get to that point where the service's main function takes place, that means I get to the point where the real work of the service should take place. But as I said before, the service crashes while trying to start it up. That's a little strange to me. Maybe someone encountered a similar problem before or can give me some hint or help. That would be very nice. I know this description is a little bit vague, but it's not that easy because I can't figure out WHERE my service crashes. That's in fact my problem :( Ah I forgot to mention, that I am using WinXP. Maybe that's important...

    C C 2 Replies Last reply
    0
    • F FreeCastle

      Hi, with the help of MSDN I wrote my own little (pure) Windows Service, that doesn't do anything. I also implemented the ability to install/uninstall this service in the service database. My problem now is, that if I want to start that service from the system control in windows it crashes with a well known error message like this: "The instruction at 0xnnnnnnn referenced memory at 0xnnnnnnn. The memory could not be written." I then wrote a simple logging-function, which prints the status information about my service to a file. And when I look at this file it seems that all is correct. All things are initialized and so on. And I also get to that point where the service's main function takes place, that means I get to the point where the real work of the service should take place. But as I said before, the service crashes while trying to start it up. That's a little strange to me. Maybe someone encountered a similar problem before or can give me some hint or help. That would be very nice. I know this description is a little bit vague, but it's not that easy because I can't figure out WHERE my service crashes. That's in fact my problem :( Ah I forgot to mention, that I am using WinXP. Maybe that's important...

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      maybe posting your code will help...

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      1 Reply Last reply
      0
      • F FreeCastle

        Hi, with the help of MSDN I wrote my own little (pure) Windows Service, that doesn't do anything. I also implemented the ability to install/uninstall this service in the service database. My problem now is, that if I want to start that service from the system control in windows it crashes with a well known error message like this: "The instruction at 0xnnnnnnn referenced memory at 0xnnnnnnn. The memory could not be written." I then wrote a simple logging-function, which prints the status information about my service to a file. And when I look at this file it seems that all is correct. All things are initialized and so on. And I also get to that point where the service's main function takes place, that means I get to the point where the real work of the service should take place. But as I said before, the service crashes while trying to start it up. That's a little strange to me. Maybe someone encountered a similar problem before or can give me some hint or help. That would be very nice. I know this description is a little bit vague, but it's not that easy because I can't figure out WHERE my service crashes. That's in fact my problem :( Ah I forgot to mention, that I am using WinXP. Maybe that's important...

        C Offline
        C Offline
        Cristian Amarie
        wrote on last edited by
        #3

        You can debug your service, and this is the best way to understand what happens. Install the service with own process and interact with desktop, then place somwehere in code (in control dispatcher, or even service main) a DebugBreak call. Go in admin tools/services, start the service; when the service will hit the DebugBreak call will invoke debugger, and you have now the chance to enter in Visual C++ debugger and check step by step the troubled piece of code.

        F 1 Reply Last reply
        0
        • C Cristian Amarie

          You can debug your service, and this is the best way to understand what happens. Install the service with own process and interact with desktop, then place somwehere in code (in control dispatcher, or even service main) a DebugBreak call. Go in admin tools/services, start the service; when the service will hit the DebugBreak call will invoke debugger, and you have now the chance to enter in Visual C++ debugger and check step by step the troubled piece of code.

          F Offline
          F Offline
          FreeCastle
          wrote on last edited by
          #4

          Mh... I made a new project for my windows service and placed my real application code in there, and what shall I say.. it works perfectly. I just made some refactorings to my original windows service code... don't know why it works now. Anyway thank you for your help. I will remember that tip with the debugging.

          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