开发者

Visual Studio 2010 Not Debugging .NET 2.0 Code

Please stick with me, this is a strange one.

Since upgrading from VS2008 to VS2010, some guys at work (and myself) found that we could no longer debug into our code. None of our breakpoints were being hit.

Without giving too much away, my work consists of writing .NET apps which run on top of a custom platform application we’ve developed. These apps are compiled to .NET 2.0. Debugging typically involves setting our platform app's exe as the startup prog开发者_StackOverflow社区ram to debug into, and launching from there.

Interestingly, none of our developers working on Vista/Windows 7 machines had any issue – just the Windows 2003/XP crowd.

Something about the combination of Visual Studio 2010, .NET 2.0, and Windows XP meant that we could no longer debug into our applications.

I have absolutely no idea why this issue should arise only in Windows 2003 and XP machines. Can anyone shed any light?


I've managed to find a workaround, thanks to this post. The issue seems to be that when debugging into code which is invoked from a native exe, Visual Studio will assume you’re debugging in .NET 4.0. Subsequently all your .NET 2.0 code will run, but the debugger won’t hit any of your breakpoints.

The fix is to give the debugger a helpful hint, in the form of a .exe.config file in the directory you’re launching your startup exe from. Something along the lines of:

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

This works as a fix, but doesn't actually answer why this happened in the first place.


Try deleting the user option files for the projects and solution. Delete all obj and bin folders. More importantly, clear out the temporary files.

Using Visual Studio 2008 temporary files, for example:

  • ("%APPDATA%") & "\Microsoft\VisualStudio\9.0\ProjectAssemblies")
  • ("%USERPROFILE%") & "\Local Settings\Application Data\ApplicationHistory")
  • ("%USERPROFILE%") & "\Local Settings\Application Data\Microsoft\VisualStudio\9.0\ProjectAssemblies")
  • ("%WINDIR%") & "\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files")

Real Life Example

I was debugging the Coding4Fun's Searching the Desktop VB.NET code at http://blogs.msdn.com/b/coding4fun/archive/2007/01/05/1417884.aspx. I noticed that on some source code files, the Navigation Bar was missing. Moreover, on the Editor's context menu the "Go To Definition" menu item was disabled. I closed Visual Studio, deleted the solution .suo file and all project .user files, re-opened the solution, and everything was back to normal.


I struggled with this problem and could not use the config file with Outlook. Outlook complained when it tried to launch. So, I did find another work-around. I change the target platform to 4.0 instead of 2.0. This brings back my debug mode. I change it back before publishing and then do additional testing on another 2.0 machine without debug.


I had this problem as well. After I converted a solution in Visual Studio 2010, the debug button did not work. In troubleshooting the problem I found that I could not delete one or two of the various files in the bin\debug folder. It might have been the .vshost.exe file. The lock on the file made me realize I had the solution open and minimized in Visual Studio 2008. Whoops :) I closed VS 2008, and it worked in VS 2010.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜