How to debug a CLR Stored procedure in VS 2013

只愿长相守 提交于 2019-12-08 05:51:05

问题


I have tried different ways to get this done but nothing works. VS seems to ignore all my breakpoints in the .cs files when I run the test script. I have included a breakpoint in the test script as well but still its not debugging.

This is the guide from Microsoft https://msdn.microsoft.com/en-us/library/ms165051(v=vs.100).aspx which I tried, but I don't have "a Set as Default Debug Script" option when I right click on my Script file.


回答1:


You might need to also:

  1. Run Visual Studio as an Admin
  2. Open up additional ports that are, by default, blocked by Windows Firewall
  3. Set the project as a Startup Project.
  4. In Visual Studio: go to "SQL Server Object Explorer", right-click on the Instance this is deploying to in the "Debug" tab of "Project Properties", and select "Allow SQL/CLR Debugging", and click the "Yes" button in the pop-up dialog.
  5. If you want breakpoints to work, you cannot have the "Optimize Code" option checked in the "SQLCLR Build" tab of "Project Properties". By default it is unchecked for the "Debug" configuration and checked for the "Release" configuration. The configuration itself doesn't matter, just so long as that option is not checked. If it was, you need to uncheck it and re-publish and make sure that it actually updates the Assembly (sometimes it might not since there are no other changes to the Assembly).
  6. In Visual Studio: Open a new query from "SQL Server Object Explorer" and in the drop-down attached to the Execute ">" button, select "Execute With Debugger" (which is also ALT + F5). Sometimes breakpoints aren't trapped the first time around, so just execute with debugger again.
  7. Please note: the login that you connect to SQL Server as for debugging needs to be a sysadmin.

There might be some additional things, but I am pretty sure that you do not need a default debug script, even though some posts about this say that you do.

Please see my answer here and the links in comments on the Question:

Can't attach to SQL Server to debug SQLCLR Stored Procedure



来源:https://stackoverflow.com/questions/45301151/how-to-debug-a-clr-stored-procedure-in-vs-2013

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