Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

c# - System.Diagnostics.Debugger.Debug() stopped working

I'm working on a program which uses the System.Diagnostics.Debugger.Break() method to allow the user to set a breakpoint from the command-line. This has worked fine for many weeks now. However, when I was working on fixing a unit test today, I tried to use the debug switch from the command-line, and it didn't work.

Here's what I've tried:

  • I've confirmed that the Debug() method is really being called (by putting a System.Console.WriteLine() after it)
  • I've confirmed that the build is still in Debug
  • I've done a clean build
  • I've restarted Product Studio

A quick Google search didn't reveal anything, and the API documentation for .Net doesn't mention anything about this function not performing correctly. So... any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I finally figured out what was happening. For some reason, something changed on my machine so that just calling Debugger.Break wasn't sufficient anymore (still don't understand what changed). In any case, I can now cause the debugger to come up by using:

if (Debugger.IsAttached == false) Debugger.Launch();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...