How to debug LinqPad query in Visual Studio Debugger?
I can attach the debugger and get it to break - but it has troub开发者_如何学Gole finding the .cs file, I think LinqPad deletes it as part of its build.. 8-(
If you call
Debugger.Launch();
Debugger.Break();
to initiate the breakpoint within your LINQPad script, LINQPad will guess that you want to use VS to debug your script and won't delete the .cs file.
- Start LINQPad
- In VS, open Debug -> Attach to Process...
- Choose LINQPad.exe
- Set breakpoint in your code called by LINQPad C# code, or write Debugger.Break() in your LINQPad script where you want the debugger to halt.
- Execute the script from LINQPad and watch the magic.
If your LINQPad code is calling a method in some referenced C# assembly and you want to debug that assembly in Visual Studio 2015, this worked for me:
- Build your solution.
- Optionally, run your LINQPad script, let it crash, etc. In the lower right LINQPad status bar, notice the PID in light blue coloring.
- In VS, CTRL + ALT + P to attach to process. Attach to the LINQPad UserQuery process with the PID you saw.
- Place a breakpoint here in VS.
- Run the linqpad query and pop over to VS. You should hit your breakpoint!
精彩评论