0

I'm currently developing a c# .net service for a client. I had issues with debugging .net service in the past so I added the Debug.Launch(); bit of code so that my IDE would launch on startup as suggested by Easier way to debug a Windows service. All of that works great.

But then it came time for launch, I turned off debugging...and it still did it! wha?! So as a solution I ripped out all debug startup code....and it still asks to load a debugger. I tried installing with release mode and it still does this. I can simply click no to continue...but that is not acceptable for a client.

Any suggestions on what I might be missing?

Community
  • 1
  • 1
Script and Compile
  • 986
  • 2
  • 8
  • 17
  • 6
    You know that by default Visual Studio builds Release into a different folder? Did you re-register your service in Windows so that it now looks at release location (\bin\Release\)? – Dmitry Aug 10 '11 at 20:31
  • You really shouldn't be getting the attach issue if you have removed it from code, I suspect that somehow your original version is the one that is running. check your GAC and make sure your libraries aren't installed in it, since it takes precedent over local dlls. – kay.one Aug 10 '11 at 21:16

1 Answers1

2

When VS debugger gets attached to the process you will see the stack trace. This will help you find the reason. It will stop on the Debugger.Launch() call if this call is what triggers debugger launch. And as I said in comment you might need to simply reregister your service in windows because VS builds release version in bin/Release, not in bin/Debug where you registered it originally.

Dmitry
  • 15,996
  • 2
  • 37
  • 65
  • Sorry, I should have specified. It can't be a GAC issue because I'm using a custom installer on a clean build in release mode on a customers machine. Hence the 'wtf' face I made when that happened. I'm not exactly sure what is going on here. I tried debugging it...and it's right at the start of the program so it's not a bug. I'm not exactly clear on what the issue is. I'll keep checking and when I figure it out I will post what the solution was. – Script and Compile Aug 11 '11 at 15:53
  • It may be that you have a crash that is unrelated to Debugger.Launch code you use to have. It maybe something like missing dll and windows just prompts to attach debugger because apparently you have it installed on customers machine. – Dmitry Aug 11 '11 at 16:07
  • Well it turns out another developer put Debugger.Launch() in the code in another location. I didn't know anything about it and had made the silly assumption (we all know about assumptions) that it wasn't there. It was buried deep into the code during a lot of fiddling so I missed it. Thanks for the help. Moral of the story: search for Debugger.Launch() before you do anything else. – Script and Compile Aug 15 '11 at 17:40