如何在VS 2013中调试CLR存储过程 [英] How to debug a CLR Stored procedure in VS 2013

查看:142
本文介绍了如何在VS 2013中调试CLR存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了多种方法来完成此操作,但是没有任何效果。当我运行测试脚本时,VS似乎忽略了.cs文件中的所有断点。我在测试脚本中也包含了一个断点,但仍然无法调试。

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.

这是Microsoft https://msdn.microsoft.com/zh-CN/library/ms165051(v = vs.100 ).aspx ,但是我右键单击脚本文件时没有设置为默认调试脚本选项。

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. 以管理员身份运行Visual Studio

  2. 打开默认情况下被Windows防火墙阻止的其他端口

  3. 将项目设置为启动项目。

  4. 在Visual Studio:转到 SQL Server对象资源管理器,在项目属性的调试选项卡中右键单击要部署到的实例,然后选择允许SQL / CLR调试,然后单击是

  5. 如果要使用断点,则不能使用 O在项目属性的 SQLCLR构建选项卡中选中了优化代码选项。默认情况下,不选中调试配置,不选中发行配置。只要没有选中该选项,配置本身就没有关系。如果是这样,则需要取消选中它,然后重新发布,并确保它确实更新了Assembly(有时可能不会更新,因为Assembly没有其他更改)。

  6. 在Visual Studio:从 SQL Server对象资源管理器中打开一个新查询,并在执行>按钮所附的下拉列表中,选择使用调试器执行(也是 ALT + F5 )。有时断点并不是第一次被困住,因此只需再次使用调试器即可。

  7. 请注意:您连接到SQL Server进行调试的登录名必须为 sysadmin

  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:

无法连接到SQL Server来调试SQLCLR存储过程

这篇关于如何在VS 2013中调试CLR存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆