Answered by:
VS2010 Breakpoints do not work when debugging dll

-
If I create a WIndows Form or WPF project, breakpoints work fine. If I create a class library project that is run inprocess (Excel, Word, AutoCAD, etc.), the breakpoints are not hit. They appear as solid red and, yes, I am loading the correct dll build. I'm using Windows 7 Ulitmate x64.
I've tried deleting the bin & obj folders then recompiling. Also tried copying project to new location as well as starting another one from scratch. All give the same result. Any ideas??? I'm stumped!
Thanks! Mike
Question
Answers
-
Yes, this does fix the issue. You need to modify ACAD.EXE.CONFIG because it is the host application.
Mike
Thank you Mike.
Now I understand my mistake: I found <My application name>.exe.config in my plagin's directory. :)
Now (in Acad.exe.config file) I uncomment block:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup>
And that fixed the issue.
Thank's for help! :)
But I have other problem now:I can't load in AutoCAD plagins v3.5if I change in config-file v4.0 to v2.0 (3.5 runs on the CLR 2.0), then I get it:
---------------------------
Microsoft Visual Studio
---------------------------
Error while trying to run project: Unable to start program 'C:\Program Files\AutoCAD 2009 ENU\acad.exe'.
Unable to load the CLR. If a CLR version was specified for debugging, check that it was valid and installed on the machine. If the problem persists, please repair your Microsoft .NET Framework installation via 'Programs and Features' in Control Panel.
---------------------------
ОК
---------------------------
It's my config-file for AutoCAD 2009:=========================================================================<configuration>
<startup>=========================================================================
<!--We always use the latest version of the framework installed on the computer. If you
are having problems then explicitly specify .NET 2.0 by uncommenting the following line.-->
<supportedRuntime version="v2.0"/>
</startup>
<!--All assemblies in AutoCAD are fully trusted so there's no point generating publisher evidence-->
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
<P.S. Sorry for my english.>- Marked as answer by Hongye Sun - MSFTModerator Tuesday, April 20, 2010 8:52 AM
All replies
-
Hello Mike,
Thanks for reporting this issue.
Are you debugging plug-in for other application? Please follow the steps as below to troubleshoot the issue:
1. In Debug Mode, open menu Debug / Windows / Processes
2. Check if the debug type includes Managed in process window
3. Open menu Debug / Windows / Modules
4. Check if DLL path and symbol path are correct
5. At the line of your breakpoint, please write System.Diagnostics.Debugger.Break();
6. Pop up a dialog at the breakpoint line
Please let me know the results. Thanks.
Hongye Sun [MSFT]
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg @ microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
See what's happening in MSDN forum? Follow us at Twitter. -
Thank you for replying - I really appreciate it!!!
Yes, I am debugging a plug-in for another application. In this case, I have a plug-in written for AutoCAD.
#2 is correct - it is managed.
#4, nothing appears in the Modules window
#5, Debugger.Break does not break
#6, I added a messagebox the line after the Debugger.Break and it does fire - so I am using the correct dll
I'm not sure what this tells us, though.
Thanks again!
Mike
-
#5, Debugger.Break does not break
#6, I added a messagebox the line after the Debugger.Break and it does fire - so I am using the correct dll
That looks too weird...
Sorry, offend its not my intention, but, are you really debugging?
Maybe your keyboard has the Ctrl key sticked, so Ctrl F5 is Run without debug by default (that happens to me once).
-
No offense taken :)
No problem with the keys because I wrote a quick Windows Form app and it debugs properly. This is only occuring with in process debugging.
I have even migrated a couple of in process projects that worked fine in VS2008 and they have the same problem in VS2010.
I'm at a total loss on this!
-
Hi Mike,
As celerino said, this case is very weired.
Can you switch to another machine and check if the debugger works correctly?
You may not see any modules in the modules window because your assembly has not been loaded into the process. Can you recheck it after the dialog is popped up?
Thanks
Hongye Sun [MSFT]
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg @ microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
See what's happening in MSDN forum? Follow us at Twitter. -
Hi Mike,
Is there any update on this issue? Thanks.
Hongye Sun [MSFT]
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg @ microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
See what's happening in MSDN forum? Follow us at Twitter. -
My apologies Hongye, I was off for a couple of days.
Nothing appears in the Module window during or after the dialog box appears. I don't have access to another x64 machine to try it but I did do an uninstall & reinstall and the problem is still there. Any other ideas?
Thanks,
MIke
-
Is it possible that your assembly is being changed by a post-build action? Some tools do that for you, such as PostSharp which disassembles your dll to inject some code in it and reassembles it. If that's the case do you have the option "Enable Just My Code" (in visual studio debugging options) disabled?
You could also check the properties of your breakpoint and under location select "Allow the source code to be different from the original version".
-- Blog: http://geeklyeverafter.blogspot.com/ -
-
Yep, I checked both of those and the problem persists. I also installed the released version of VS2010 and the problem is still there. Since I did not have another x64 box, I had a colleague try it and he has the same problem. At this point, I'm stumped and have no idea where to lok next :(
-
This issue is likely occuring because you are developing a .NET 3.5 plugin but Visual Studio 2010 is attaching to the third party application with the .NET 4.0 debugger (default). Please see my response athttps://connect.microsoft.com/VisualStudio/feedback/details/487949/debugging-external-application for more details and a detailed explanation of the workaround.
Quidkly, if that is the cause, the solution for this is to either launch the third party application manually and then attach, or to add a <startup> section to an <application name>.exe.config file letting Visual Studio know which version of the debugger to attach to the third party application with (e.g.):
<startup>
<supportedRuntime version="v2.0.[version on your machine]" />
</startup>
Best Regards, Andrew Hall. Visual Studio Debugger. -
This issue is likely occuring because you are developing a .NET 3.5 plugin but Visual Studio 2010 is attaching to the third party application with the .NET 4.0 debugger (default). Please see my response athttps://connect.microsoft.com/VisualStudio/feedback/details/487949/debugging-external-application for more details and a detailed explanation of the workaround.
Quidkly, if that is the cause, the solution for this is to either launch the third party application manually and then attach, or to add a <startup> section to an <application name>.exe.config file letting Visual Studio know which version of the debugger to attach to the third party application with (e.g.):
<startup>
<supportedRuntime version="v2.0.[version on your machine]" />
</startup>
Best Regards, Andrew Hall. Visual Studio Debugger.Thank you for your answer.
But, it's not exe-application, it's dll-library (managed plagin for unmanaged application (AutoCAD)). Thereby <application name>.exe.config be absent. (((
<P.S. Sorry for my english.>
-
-
-
Yes, this does fix the issue. You need to modify ACAD.EXE.CONFIG because it is the host application.
Mike
Thank you Mike.
Now I understand my mistake: I found <My application name>.exe.config in my plagin's directory. :)
Now (in Acad.exe.config file) I uncomment block:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup>
And that fixed the issue.
Thank's for help! :)
But I have other problem now:I can't load in AutoCAD plagins v3.5if I change in config-file v4.0 to v2.0 (3.5 runs on the CLR 2.0), then I get it:
---------------------------
Microsoft Visual Studio
---------------------------
Error while trying to run project: Unable to start program 'C:\Program Files\AutoCAD 2009 ENU\acad.exe'.
Unable to load the CLR. If a CLR version was specified for debugging, check that it was valid and installed on the machine. If the problem persists, please repair your Microsoft .NET Framework installation via 'Programs and Features' in Control Panel.
---------------------------
ОК
---------------------------
It's my config-file for AutoCAD 2009:=========================================================================<configuration>
<startup>=========================================================================
<!--We always use the latest version of the framework installed on the computer. If you
are having problems then explicitly specify .NET 2.0 by uncommenting the following line.-->
<supportedRuntime version="v2.0"/>
</startup>
<!--All assemblies in AutoCAD are fully trusted so there's no point generating publisher evidence-->
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
<P.S. Sorry for my english.>- Marked as answer by Hongye Sun - MSFTModerator Tuesday, April 20, 2010 8:52 AM
-
Hi Andrew,
This workaround came at a very good time.
I'm developping add-ins for an Electrical CAD software (www.eplan.de), and I was seeing the exact same problem, which of course drove me mad !
Thanks a lot.
Luc Morin, T.P. http://www.stlm.ca -
I've been developing excel addin with the previous version of VS, and having the same problem as everyone in VS2010. Could someone please point me to where I can find the <???>.config file for excel (in my situation) to make VS2010 startup debugger in v2.0 .net framework?
Thanks
-
The excel.exe.config file may not exist (you may need to create one), but the *.exe.config file always sits next to the *.exe file, so it will be (or need to be created) next to your excel.exe file (most likely in C:\Program Files\Microsoft Office\Office<version #>)
Best Regards, Andrew Hall. Visual Studio Debugger. -
Hi,
I encountered the same issue debugging AutoCAD 2008 with Visual Studio 2010. I tried several entries for the supported runtime tag and the following one worked for me:
<supportedRuntime version="v2.0.50727" />
The version told me in the system configuration is stil another one, but this one worked and I'm able to debug.
HTH
Rene
-
-
Perfect.
I was having the same issue when debugging a WPF control for an ArcGIS 10 Add-in. Changing the supportedRuntime in the ArcGIS\Desktop10.0\Bin\ArcMap.exe.Config fixed the problem.
<startup> <!-- <supportedRuntime version="v2.0.50727"/> --> <supportedRuntime version="v4.0"/> </startup>
Thanks!
- Proposed as answer by Fremton39 Thursday, November 11, 2010 2:57 PM
-
Hello
I had the similar problem and you workaround helped me but only partially.
So, my story:
I'm developing a plugin for AutoCAD 2009. When I run AutoCAD without debugging all command from my plugin are available. But when I run it from debug plugin initialization passes successfully but then no command works. There were no problems when I used VS 2008.
-
-
-