none
VS2010 Breakpoints do not work when debugging dll

    Question

  • 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

    Friday, March 26, 2010 9:15 PM

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.5
    if 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.>
    Sunday, April 18, 2010 7:22 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.
    Monday, March 29, 2010 6:52 AM
    Moderator
  • 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

    Monday, March 29, 2010 7:15 PM
  • #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). 

     

    Tuesday, March 30, 2010 11:04 PM
  • 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!

    Wednesday, March 31, 2010 2:41 AM
  • 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.
    Thursday, April 01, 2010 4:50 AM
    Moderator
  • 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.
    Tuesday, April 06, 2010 4:00 AM
    Moderator
  • 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

    Wednesday, April 07, 2010 2:03 PM
  • 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/
    Wednesday, April 07, 2010 2:42 PM
  • God day.

    I write plagn for AutoCAD 2009/2011, and I have in MS Visual Studio 2010 it problem too (in VS2008 all was fine).

    I set "Enable Just My Code" = false, and I set "Enable Just My Code" = true... but it has not helped me. (((

     

    Friday, April 16, 2010 10:48 AM
  • 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 :(

    Friday, April 16, 2010 1:37 PM
  • 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.
    Saturday, April 17, 2010 12:33 AM
    Moderator
  • 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.>

    Saturday, April 17, 2010 6:10 AM
  • Ah! Thank you Andrew! That fixed the issue. I *really* appreciate your help and everyone else's, too.

    Best Regards,

    Mike

    Sunday, April 18, 2010 3:38 AM
  • Yes, this does fix the issue. You need to modify ACAD.EXE.CONFIG because it is the host application.

    Mike

    Sunday, April 18, 2010 3:40 AM
  • 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.5
    if 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.>
    Sunday, April 18, 2010 7:22 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
    Wednesday, April 21, 2010 3:33 PM
  • 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

    Thursday, April 22, 2010 4:16 AM
  • 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.
    Friday, April 23, 2010 9:20 PM
    Moderator
  • 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

     

     

    Tuesday, April 27, 2010 12:45 PM
  • The correct version will be the most recent v2.0.xxxxx folder in the "C:\Windows\Microsoft.NET\Framework" directory


    Best Regards, Andrew Hall. Visual Studio Debugger.
    Wednesday, April 28, 2010 11:33 PM
    Moderator
  • 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
    Tuesday, August 31, 2010 1:24 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.

     

    Sunday, December 12, 2010 1:55 PM
  • Do you have a crystal reports in your .dll file?  
    Wednesday, February 02, 2011 11:20 PM
  • Thanks very much.  This was exactly what we needed.

    Monday, March 14, 2011 11:46 AM
  • Thanks Andrew, this also helped me to solve my problem!
    Monday, April 04, 2011 3:25 PM