Debugging a .NET Framework 2.0/3.0/3.5 class library with VS 2010

A number of people have had difficulty debugging a .NET Framework 2.0/3.0/3.5 class library that loads into a native executable. The debugger will launch, and their code will run, but the debugger will not stop at breakpoints, detect that modules load, etc.

The problem is that the debugger is trying to determine what version of the .NET Framework your class library will load into, and the debugger has guessed incorrectly.

The work around for this is to add a config file next to the native executable to tell the debugger what version of the .NET Framework to debug.

So if you are trying to debug c:\proj\MyNativeProject\debug\MyNativeProject.exe, then create c:\proj\MyNativeProject\debug\MyNativeProject.exe.config with this content:

<?xml version ="1.0"?>
<configuration>
    <startup>
        <supportedRuntime version="v2.0.50727" />
    </startup>
</configuration>