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

ぃ、小莉子 提交于 2019-12-07 12:43:12

问题


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.

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:

  1. 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.
  2. 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");
    }
    
  3. I edited the Target Connection String in the project properties to connect to the new database and successfully got a connection when pressing the connection button. The connection string used Windows Authentication for me, with the same user as the database owner.
  4. I built and deployed the solution and checked the SQL Object Explorer to ensure that the SP was deployed. It was.
  5. I selected the server and, using the right click, selected the "Allow SQL/CLR Debugging". I checked it again to ensure it was actually set.
  6. I selected the stored procedure and with the right click, selected "Debug Procedure..."
  7. The debug script was displayed. I stepped to the line to exec the SP and then pressed F11 to step in. At this point I was shown the following:
  8. I pressed the attach and was shown the following error:

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? Thanks Craig


回答1:


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.



来源:https://stackoverflow.com/questions/42785521/cant-attach-to-sql-server-to-debug-sqlclr-stored-procedure

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