Del via


Debugger not working

 

Problem Description
================

When you try to debug a simple windows application in Visual Studio 2005, you get the following error :

----------------------------------
Microsoft Visual Studio
----------------------------------
Unable to start program '<application_name>'.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 Shared\VS7Debug\msdbg.dll"'.
----------------------------------
OK  
----------------------------------

 

Diagnostic
=======

We can use Debugger Diagnostic Tool to find out any error about this :

This Tool is available here.

In order to simulate the problem, i tried to rename the msdbg2.dll file on my system and then run the DebuggerDiagnostic tool. The output that i get on my system is the following :

C:\Documents and Settings\prabhatt\My Documents\MSDN\Debugger Diagnostics>DebuggerDiagnostics.exe

Begin 'CheckMDMImage()'
mdm.exe: version '7.10.3077' with hash '{6607858A-7B579EC3-E062DAB3-BF891368-CBF1CB9C}'.
Result of 'CheckMDMImage()' is '00000000'

Begin 'CheckMSDBG2Image()'
Could not calculate hash for 'msdbg2.dll' - 0x80070002
Result of 'CheckMSDBG2Image()' is '80070002'

...

Begin 'CoCreateMachineDebugManager(&spMachine)'
Result of 'CoCreateMachineDebugManager(&spMachine)' is '8007007e'

 

Analysing the report
===============

We found that the following portion is reporting some error :

Begin 'CheckMSDBG2Image()'
Could not calculate hash for 'msdbg2.dll' - 0x80070002
Result of 'CheckMSDBG2Image()' is '80070002'

It states that it is unable to calculate the HASH value of the msdbg2.dll. Which indicates that there might be some problem with this DLL.

 

Root Cause
=======

There are three causes of this issue :-
1. The dll is not present physically at the specified path.
2. The dll is corrupted due to some unknown reason.
3. The dll is not the original one that comes with Visual Studio.

 

Conflict/Corrupt or missing msdbg2.dll
=======================

Once we identify that there are some issues with this dll, lets start identifying what might be the reason.

1. Manually search for the file in the directory C:\Program Files\Common Files\Microsoft Shared\VS7Debug

Is the file present there? If no we need to install the file there and register it properly.

There are several public sites from where we can download, install and register it. Since these sites might not be safe. I would recommend you to try installing the files from the installation disks of Visual Studio that you have.

2. If the file is physically present there, then it might be corrupted. So go ahead and install the new file from the installation disk and register it.

3. One interesting thing is that Office XP installation and Office XP update KB833858 also contain the same file msdbg2.dll. So if by any chance, if this file is installed by accident to the directory(C:\Program Files\Common Files\Microsoft Shared\VS7Debug) then also we may get this issue. We can verify this by checking the version, the file that comes with Visual Studio 2005 has the version 8.0.50727.42. On the other hand the file that comes with Office XP update (KB833858) has the version 7.0.9466.0. If this is the case unregister the dll. Install the original one and register it.

 

How to Unregister a dll
==============

1. Start->Run->cmd.
2. At a command prompt, type the following command:
regsvr32 /u <path_of_msdbg2.dll>\msdbg2.dll 

 

How to Register a dll
=============

1. Start->Run->cmd.
2. At a command prompt, type the following command:
regsvr32 <path_of_msdbg2.dll>\msdbg2.dll

Comments

  • Anonymous
    October 29, 2010
    A similar msdbg2.dll problem in file-shared remote debugger scenerio.
  • Problem Description (Error messages may differ. Not English language locale on both side.) remote debug monitor: connected. Visual Studio 2005: Unable to connect to '<server-name>', ...(other part of the message is the same).
  • Diagnostic Debugger diagnostic tool reports the Visual Studio side has msdbg2.dll of version 8.0.50727.42; monitor side msdbg2.dll 7.10.3077.0.
  • Analysis A different msdbg2.dll on monitor side leads to a conflict. The monitor side has Visual Studio 2003 installed. This might be the root cause.
  • Solution Unregister msdbg2.dll on the monitor side.
  • Conclusion In file-shared remote debugger scenerio, a. msdbg2.dll registration is not needed on the monitor side; b. if a different msdbg2.dll is registered on the monitor side, debug connection may fail.