So we're in a windows server 2008 environment where multiple developers are terminaled in, working on different parts of the same code. (I know, it's ugly, no revision control.) The question is, and would kinda be regardless, If someone uses Debugger.Launch() to debug a web service, to which user does the message asking if the user wants to debug get sent? I ask, because I'm logged on as one user trying to debug the code, but the other user is getting the message. I'd like to know how to get it to send the message to me.
Asked
Active
Viewed 1,550 times
0
-
1Is he the one that's executing the code when the `Debugger.Launch()` line is hit? I'm not sure if there's a way around that... you could check the username before executing that line of code: http://stackoverflow.com/questions/3175004/get-windows-user-name-different-methods – Jeff B Dec 10 '12 at 20:15
-
I'm actually executing the code from a SOAP client so it's ... ... Actually, I think she's logged on as the app pool identity of the webapp the service is running on. Maybe that's it. – PrinPlup Dec 10 '12 at 21:15
-
Ok, so in this case it really looks like whatever account is running the code will be the one to get the message if there's a terminal session open for it. If not, the debugger looks for any other active sessions to send the message to. If none are found, it just continues processing. – PrinPlup Dec 11 '12 at 20:19
-
I think you can post that yourself as the answer to your question. That way people can upvote it, etc. – Jeff B Dec 11 '12 at 20:34
-
I'd just as soon, you did since you actually put me on the right path. – PrinPlup Dec 19 '12 at 17:07
-
A web service runs in the context of a Windows Service (like IIS), and runs under *that* user's context. Users "logged in" or "Terminaled" in are in a different context. I suggest you use Remote Debugging and not Debugger.Launch – Peter Ritchie Dec 21 '12 at 17:41
-
See also http://msdn.microsoft.com/en-us/library/ms165008(v=vs.80).aspx – Peter Ritchie Dec 21 '12 at 17:45
-
Can you install IIS on your personal development machine, create a copy of the site/services and run it. Attach the debugger to `w3wp.exe` then debug it in VS? – Amicable Dec 21 '12 at 18:24
1 Answers
-1
The Debugger.Launch()
statement will launch the debugger dialog for whatever account it's running under, assuming there's a terminal session open for it. If not, it'll look for any other active sessions that it can send the message to. If this fails, it'll just continue to run.
So if you've got a Debugger.Launch()
statement in the server-side code for a project and are not running it locally (via IIS or something), it will probably not work the way you are wanting it to ;)
(Summary of the content in the question comments)

Jeff B
- 8,572
- 17
- 61
- 140
-
Debugger.Launch is not going to have a desktop to display forms and dialogs to a user if it is invoked within the context of a Windows Service (i.e. Web Service running under IIS, WAS, etc.). – Peter Ritchie Dec 21 '12 at 17:42
-
Hmm, then why did the other user get the 'Choose your debugger' dialog? – Jeff B Dec 21 '12 at 22:25
-
Are they running the service with "interact with desktop"? If you have multiple users logged-in, it will appear like it's randomly picking desktops because there's more than one. This would make it impossible to deterministically get "choose your debugger" on a particular desktop. – Peter Ritchie Dec 22 '12 at 04:10
-
I don't know, I was just curious on what might explain the behavior described in the question. – Jeff B Dec 23 '12 at 23:53
-
I just tried this on my machine with a Windows Service "Log On As" set to "Local Service". `Debugger.Launch()` produced a prompt for me to chose a debugger. I haven't tested it with a Web Service though. – Jeff B Dec 31 '12 at 16:37