How to debug LinqPad query in Visual Studio Debugger?

倾然丶 夕夏残阳落幕 提交于 2019-12-18 10:38:13

问题


I can attach the debugger and get it to break - but it has trouble finding the .cs file, I think LinqPad deletes it as part of its build.. 8-(


回答1:


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.




回答2:


  • 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.



回答3:


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:

  1. Build your solution.
  2. Optionally, run your LINQPad script, let it crash, etc. In the lower right LINQPad status bar, notice the PID in light blue coloring.
  3. In VS, CTRL + ALT + P to attach to process. Attach to the LINQPad UserQuery process with the PID you saw.
  4. Place a breakpoint here in VS.
  5. Run the linqpad query and pop over to VS. You should hit your breakpoint!


来源:https://stackoverflow.com/questions/5564369/how-to-debug-linqpad-query-in-visual-studio-debugger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!