简体   繁体   中英

Debugging Windows Service — ReVisit (Windows 7)

Hi there have been lot of discussion on this topic(Debugging Windiows service) Earlier as well https://stackoverflow.com/search?q=debug+windows+service

But am having few problems implementing the same.

  • I Tried adding attach process from VS 2008 but the particular .Exe is disabled so am not able to attach
  • Also Tried the below code using debugger

     #if DEBUG Debugger.Launch(); #endif 

Am getting Error when debugger is called "UnHandled Exception Occured--JIT compiler was launched without any security permissions.To debug run as administrator"

I have Admin rights for this PC and am using Windows 7 how can i debug it ?

PS: I can debug making this an Console application. But want to know why the above method fails..Is there a way i can debug as a service ?

Possibly- start the JIT with proper privileges. ie start the service as administrator. You can set username and password for the service to use when starting.

When you attach the process the process should be running. These are the two ways I've used to debug services

1) Add a sleep timer in the beginning of your windows service, run the service, then in vs- Debug->attach to a process

2) Creating and Reading DUMP files (google DebugDiag [v1.2 is the newest?]) It can allow you to look for crashes in threads, memory leaks, cpu usage fluxs. Use WinDbg to read the dump files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM