问题描述
我想在SQL Server中调试SQLCLR存储过程.我一直在尝试在VS2015社区和最近安装的VS2017社区版本中调试SP,但未成功.我很确定问题出在附加到SQL Server上,但是当我完成所有可以在网上找到的内容时,却无济于事.
I want to debug a SQLCLR stored procedure in SQL Server. I have been trying to debug an SP in VS2015 Community and in the recently installed VS2017 Community editions without success. I am pretty sure that the problem lies in attaching to SQL Server but as I've done everything I can find mentioned online but to no avail.
在SQL Server Express LocalDB中创建数据库项目时,一切正常.如果我更改连接字符串以使用我的Developer Edition SQL Server,则会收到错误消息.我已经做了以下事情:
When creating the database project in SQL Server Express LocalDB everything works fine. If I change the connection string to use my Developer Edition SQL Server, I then get an error. I have done the following:
- 我创建了一个新数据库.我是服务器的唯一用户,它驻留在我用于Visual Studio的同一台台式机上.
-
在Visual Studio中,我使用简单的方法创建了一个简单的数据库项目,该方法将一些文本发送到输出管道.
- I created a new database. I am the only user of the server and it resides on the same desktop machine that I am using for Visual Studio.
In Visual Studio I created a simple database project with a simple method to send some text to the output pipe.
[Microsoft.SqlServer.Server.SqlProcedure]
public static void mytest ()
{
SqlContext.Pipe.Send("in clr Craig1");
}
此后,该过程执行并执行管道功能,但不允许我执行附件和调试.
Thereafter, the procedure executes and performs the pipe function, but it does not let me do the attachment and the debugging.
任何关于我做错事情的想法吗?谢谢克雷格
Any ideas of what I'm doing wrong?ThanksCraig
推荐答案
您可能只需要使用以管理员身份运行"启动Visual Studio.我不认为在运行Windows 8时需要这样做,但是我现在在运行Windows 10,并且绝对需要以管理员身份运行".我猜想您不能以其他方式附加到其他人的进程中(我的开发人员版运行的服务帐户为"SQL Server",但LocalDB始终作为启动它的登录名运行,通常是您自己).我尚未测试过以自己的身份运行Developer Edition是否仍然需要以管理员身份运行",或者以本地系统"身份运行Developer Edition会如何影响此行为.
You might just need to start Visual Studio with "Run as Administrator". I do not believe that I needed to do that when running Windows 8, but I am running Windows 10 now and definitely need to "Run as Administrator". I am guessing that you cannot otherwise attach to someone else's process (I have my Developer Edition running with a service account of "SQL Server", yet LocalDB always runs as the Login that started it, typically yourself). I have not tested to see if running Developer Edition as myself would still require "Run as Administrator", or how running Developer Edition as "Local System" would affect this behavior.
这篇关于无法连接到SQL Server来调试SQLCLR存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!