T-SQL Debugging – SSMS errors – MSDBG2.DLL


I hope that all of you had a chance to participate in my session on the “Underappreciated Features of Microsoft SQL Server” during the Exclusive SQL Server Webcast series on Security & Scalability. If not, I trust the recorded sessions would be up soon for you to see. I will share the location of the same once available.

During the session, I demonstrated the T-SQL Debugger (http://beyondrelational.com/blogs/nakul/archive/2011/02/02/t-sql-debugger-underappreciated-features-of-microsoft-sql-server.aspx). A week before the session, I received a new laptop from IT. I was planning to conduct the demos from the same, and hence went about testing them and running through them as if it were a live session.

But, all was not good. As soon as I started the T-SQL Debugger demo, I encountered the following error:

—————————
Microsoft SQL Server Management Studio
—————————
Unable to start program ‘MSSQL:://MyInstance/master/sys/=0’.
A debugger dll, msdbg2.dll, is not correctly installed. Please repair your Visual Studio installation via ‘Add or Remove Programs’ in control panel.
If the problem persists, you can manually register msdbg2.dll from the command prompt with ‘regsvr32 "%CommonProgramFiles%Microsoft SharedVS7Debugmsdbg.dll"’.
—————————
OK  
—————————

image

The issue in my case was a bad dll (a problem we know as “dll ghost”). Here’s how I troubleshot the error:

  1. Navigate out to the location mentioned – “%CommonProgramFiles%Microsoft SharedVS7Debug”
  2. Confirm that the dll – msdbg2.dll is present at the location
  3. Right click on the dll and note the version of the dll

Because we know that the SQL Server 2008 R2 uses the Visual Studio 2008 shell, the dll version should at least be a 9.xx.xxx. Unfortunately, in my case, it was: 7.10.3077.0 – which is a very old version.

image

I had to do the demo and most of the laptop had already been configured for my day to day activities. Therefore, I looked around for a “healthy” installation of the SQL Server and checked the version of the dll there. The version was exactly as expected:

image

So, what do I do?

  1. Close the SSMS instance
  2. Unregister the existing dll by launching the Command Prompt under the Administrator mode and using regsvr32 /u msdbg2.dll
  3. Delete the “bad” dll from the location mentioned above
  4. Copy and paste the “healthy” dll
  5. Register the dll by using regsvr32 msdbg2.dll at the administrative command prompt
  6. Restart SSMS and attempt to debug

image

Looking at the version of the bad dll, I suspect the dll was installed by Visual Studio 2003 (v7.0), and IT probably installed SQL Server before they began the Visual Studio installation (I need to use the entire spectrum – Visual Studio 6 – 2010 and only one version of SQL Server!).

Do you know of any other scenarios that would cause this issue? Please leave a note for the benefit of all.

Until we meet next time,

Be courteous. Drive responsibly.

Advertisement

1 thought on “T-SQL Debugging – SSMS errors – MSDBG2.DLL

  1. Pingback: #0382 – SQL Server – SSMS – Debugging a T-SQL DML Trigger | SQLTwins by Nakul Vachhrajani

Let me know what you think about this post by leaving your feedback here!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.