Visual Studio does not attaches debugger - by carlop

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


4
0
Sign in
to vote
ID 768651 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 10/24/2012 11:54:04 PM
Access Restriction Public

Description

I have a .NET 3.5 library project to debug.

To debug it I have to launch it through an external exe compiled with Delphi in native code.
This works great in visual studio 2010 and earlier, I never had any issue of any type: the debugger hits any breakpoints without problems.

 This doesn't works anymore in visual studio 2012: the debugger doesn't stops, never. I've tried both on windows 7 and windows 8 but the behavior is the same: breakpoints are simply ignored.
Sign in to post a comment.
Posted by Microsoft on 10/30/2012 at 11:29 AM
Hi carlop,

Glad the solutions work for you. Yes, please assume the behavior of VS 2012 will be the way forward.
Posted by carlop on 10/29/2012 at 12:15 AM
Hi

Thanks very much for the explanation.
Your suggestion works perfectly.

Just a final question: Since VS2010 also was aware of the .Net 4.0 I guess this is a change has been made in VS2012, my question is: is this the expected future behavior or there's a plan to let it work such as in VS2010 ?
Posted by Microsoft on 10/26/2012 at 3:40 PM
Hi carlop,

Thank you for reporting the issue. Good news is, I was able to repro the issue and I have answers for you! Bad news is, this is a tricky one to explain by words, so please bear with me :)

First, let me paraphrase what Visual Studio sees when it opens the project you sent us: "When 'Start Debugging', launch the debugger on the external program, 'InteropTestApp.exe', which is not built by the current solution/project. I chose the target framework under "Application" tab to be .Net 3.5, but this only affects building the class library project under the current solution. This setting will not influence what debugger engine type (i.e., .net 4.0? 3.5?) VS is using to attach to the external program, 'InteropTestApp.exe'". As a result, VS does not know what .Net version the class library being loaded by your Delphi app, and by default assumes .Net 4.0. Unfortunately, .Net 4.0 debug engine does not work on .NET code v3.5 or prior.

I believe what you intend to do is to launch the debugger on the external Delphi app, but choose the target framework for the debugger to be .NET 3.5 when managed code is hit (i.e., break at the class library code). Unfortunately, the settings under the "Application" tab for the solution is for building, and will not affect debugger type when the debugger is attaching to an external app.

Solution #1: Use Debug -> Attach to Process -> Change the debugger type by hitting the "Select..." in the dialog and choosing "Managed (v3.5, v3.0, v2.0) code" -> Choose InteropTestApp.exe -> Attach. Now, you are explicitly telling VS you want to use the debug engine for .Net 3.5 or prior. Once attached, the breakpoint will hit when you do "Click Me" in your app. Downside of this is that you are not getting the "Start Debugging" behavior you intended; you are getting the "Debug Attach" experience.

Solution #2: Make your external app the "Start up project". In Visual Studio, File -> Open -> Project, and select your Delphi app (InteropTestApp.exe). You have just created a new solution with the delphi binaries as the startup project. If you go to the project properties, you can change the "Debugger Type" from 'Auto' to 'Managed (v3.5, v3.0, v2.0)'. By doing this, you have told Visual Studio explicitly you want to use the debug engine for .Net 3.5 or prior. To allow breakpoints to be set in the class library code, go to Solution Explorer -> right click on "Solution 'InteropTestApp' (1 project)" -> Add -> Existing Project -> <your class libray project InteropTestLib.csproj>. Now, the breakpoints in your class library code will hit, as long as you maintain having InteropTestApp as your startup project and setting the Debugger Type explicitly to use .Net 3.5 or prior.

Hopefully this explains everything :)
Visual Studio Debugger
Posted by Microsoft on 10/25/2012 at 1:23 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 10/25/2012 at 12:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)