Unable to debug with F5 from visual studio 2013, m

2020-06-18 17:34发布

问题:

I am trying to debug a program using start external program in Visual Studio 2013. All project files are .NET 3.5. As a sidenote: I have debugged like this since i updated to VS2013 (about two weeks), but today it suddently stopped working.

When I run the program it starts, but the Debug->Windows->Modules window is empty.

When I start the program and attach Visual Studio to process with Managed (v3.5, v3.0, v2.0) code everything loads smoothly and I am able to debug. But when I choose Managed (v4.5, v4.0) code I get the same blank modules window as above and no active breakpoints.

Could it be that start external program uses the Managed (v4.5, v4.0) code instead of Managed (v3.5, v3.0, v2.0) code? And is there any way to control which debugger Visual Studio uses when using start external program?

I have double checked that all project that builds with the debug-configuration is set to .NET 3.5 since my first thought was that one of the projects might build in a higher version. One project is .NET4.0 but is not set to build in my configuration.

回答1:

After some research I ended up adding a .config-file for each version of the executable. The config-file must be named ExecutableNameHere.exe.config.

Here is the config I used for setting the active debugger to .NET 3.5:

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

Just save the file in the same directory as the executable and the next time you debug it will use this .NET version.

For other .NET versions, replace version with the following:

  • .NET Framework 1.0: "v1.0.3705"
  • .NET Framework 1.1: "v1.1.4322"
  • .NET Framework 2.0, 3.0, and 3.5: "v2.0.50727"
  • .NET Framework 4 and 4.5 (including point releases such as 4.5.1): "v4.0"

Reference: http://msdn.microsoft.com/en-us/library/jj152935(v=vs.110).aspx