The "Unspecified error"/"Unexpected error" messages in Visual Studio .NET

If you worked with source control integration in VisualStudio .NET 2002 or VisualStudio .NET 2003, you might have seen at some point an "Unspecified error" or "Catastrophic failure" message like the ones below:

 

Visual Studio .NET 2005 displays similar "Unexpected error" messages, a bit more user-friendly and containing more debugging information:

When the source control integration package encounters an unexpected situation with which it cannot cope, it throws a _com_error exception. The exception is later caught by Visual Studio shell and an error message is displayed to the user.

If you see one of these messages, it can mean one of these things:
- you have found a bug in VisualStudio
- your machine has some configuration issues (either with Visual Studio or with your source control provider, etc)
- one of the solution or project files has some corruption

So, what can you do if you've seen one of these "Unspecified error" messages"?

If you've seen the message in VisualStudio 2005 you can start by searching your preferred search engine (search.msn.com, google.com, etc), with the exact debugging information displayed by the message (HRESULT number, file name, line number). Other people may have hit the same issue before you, and they may have already identified the cause and possibly may have a solution or workaround.

You can also ask directly the source control integration team at Microsoft by e-mailing ssnetint email alias, or even better, by opening a product bug. You can do that by going to Visual Studio Product Feedback page and follow the Report_a_bug link. When choosing to send a report to Microsoft, please attach as much information as possible, that could help developers reproduce the problem:
- attach a MINIDUMP from the moment the error was generated (not when the message is displayed!); see below how to create the minidump file.
- describe exactly what were you doing when you got the Unspecified/Unexpected error message
- if possible, attach a copy of the project or solution that caused the problem; if this is not possible, describe the structure of the solution on your local hard disk and in the source control database (project types, their disk locations, if there are files shared between projects, source control bindings of projects, etc)

How to save a minidump when the unspecified error exception is thrown

Note: If you are using VS2005 and not able to find the exact menu commands I describe below, you are probably running VS using a VB or Web profile. You should use Tools/Import And Export Settings menu command to Reset All Settings to General Development Settings or to Visual C++ Development Settings and save a backup of current settings so you can restore later your config.

  1. Start one Visual Studio application (this will be the debugee)
  2. Open the solution in this Visual Studio and start the repro sequence, stopping just before the last action that causes the message to appear.
  3. Start a second Visual Studio application (this will be the debugger)
  4. In the debugger, choose the Tools/DebugProcesses menu. A dialog will open, allowing to select the process to be debugged.
  5. Select the first Visual Studio process line (devenv.exe that is not grayed out)
  6. If using VS2002, press the Attach button, and check the Native checkbox in the dialog that opens. Ok this dialog to complete attaching to devenv.exe. Press Close button to close the Processes dialog.
    If using VS2005, press the Select button and choose Debug_these_code_type radio button and check the Native checkbox. Click Ok to close this dialog. In the Processes dialog press Attach button to attach to devenv.exe
  7. In the debugger, choose the Debug/Exceptions menu. An Exceptions dialog will open.
  8. Expand the C++ Exceptions node and select the _com_error line.
  9. If using VS2002, using the radio buttons in the bottom of the dialog, choose "When the exception is thrown"..."Break into debugger".
    If using VS2005, check the Thrown checkbox column.
  10. Click Ok to close the Exceptions dialog.
  11. Now, back in the debuggee Visual Studio, continue with the repro steps that normally would cause the "Unspecified error" message
  12. When the unexpected situation is encountered and the exception is thrown, you'll break automatically into the debugger.
  13. In the debugger, a dialog that reads something like "First-chance exception at 0xXXXXXXX in devenv.exe: Microsoft C++ exception: _com_error at memory location 0xXXXXXXX" should have popped up. Click Break button in this dialog.
  14. In the debugger, use the Debug/SaveDumpAs menu. A SaveAs window will open, allowing to select a filename for the minidump. Type a filename and click Ok in this dialog.
  15. You can now close both the debugger and the debugee Visual Studio processes.
Note: if you can't find the Tools/DebugProcesses, Debug/Exceptions or Debug/SaveDumpAs menu items, it is possible you're using a VisualStudio profile where these menus are hidden. you may need to switch first to a profile like the General Profile or the VisualC Developement profile to have the menus visible.

Note2: when saving minidumps, in the SaveAs dialog you can choose to save as Minidump or as Minidump_with_heap. You can save as one type, open the Debug/SaveDumpAs dialog again and save another file as the other type, too. Sending Microsoft a minidump with heap for investigation will help more in debugging and reproducing the issue. However, these files may get bigger even when they are archived, so if you don't have enough time to send a minidump with heap, a minidump will be usefull, too.

How to save a minidump when Visual Studio crashes during a source control operation

Although VS may crash during a source control operation, it is not always the source control integration package's fault. It may be the source control provider actually crashing, or it may be the project's code causing the access violation (e.g. when files gets reloaded in the IDE after the source control operation completed). To establish the culprit, please send Microsoft the minidump at the time the crash happened.

You can get the minidump following the steps above (for the Unspecified error), with a small difference: in steps 8 and 9, instead of trapping _com_errors, set the Visual Studio debugger to break on "Access Violations" (c0000005) and "Stack Overflows" (c00000fd) exception types, under "Win32 Exceptions" nodes (these are most common type of crashes).

(Back to SourceSafe and source control integration page)