locked
How to toggle 'enabled debuggers' from a package ? RRS feed

  • Question

  • hi.

    In the properties of a c# project, under "Debug", there is an option "Enable unmanaged code debugging". How can I turn this option on (or off) from a vs package?

    WM_THX
    -thomas woelfer


    http://www.die.de/blog

    Friday, February 21, 2014 2:58 PM

Answers

  • Hi,

    Yes, my syntax for properties was wrong, the correct one is:

    project = ...
    project.ConfigurationManager.ActiveConfiguration.Properties.Item("EnableUnmanagedDebugging").Value = true;
    

    Not all project types have the same set of properties at project level (EnvDTE.Project.Properties) and project configuration level (EnvDTE.Configuration.Properties), but I have tested it with a Windows Forms C# project in VS 2010 and the property exists and that code works.

    So, which VS version and which exact C# project type that has that setting at user interface level (Debug property page) is lacking that property at code level?


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    • Marked as answer by thomas_woelfer Tuesday, February 25, 2014 11:04 AM
    Monday, February 24, 2014 3:25 PM

All replies

  • Hi,

    That is a property of the configuration ("Debug", "Release", etc.) of a project, not a property of a project, so using the automation model (EnvDTE), given an EnvDTE.Project it would be:

    EnvDTE.Project project;

    project = ... // Get the project somehow

    project.ConfigurationManager.ActiveConfiguration.Properties["EnableUnmanagedDebugging"].Value = true;


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    Friday, February 21, 2014 3:54 PM
  • Carlos,

    thanks for the pointers; but i'm not quite there yet. I'm getting the project like this:

    vardte2 = (DTE2)GetService(typeof(DTE));
    Solution solution = dte2.Solution;

    foreach(Projectproject insolution.Projects)
    {
       if( project.Name == "kernel.native.tester" )
       { 
              // this is the one I want changed.
         }    }

    However, after having obtained the project, I cannot do this:

    project.ConfigurationManager.ActiveConfiguration.Properties["EnableUnmanagedDebugging"].Value = true;

    As far as vs is concerned, the properties cannot be indexed by strings. Instead, I tried

    foreach( Property in project.ConfigurationManager.ActiveConfiguration.Properties)
    {
       if( property.Name = "EnableUnmanagedDebugging")
       {
              // However, there is no property by that name
        }
    }

    I do get a collection of properties, however, there is none that at least looks like is has to do with the unmanged debugging. (I do get to see "OutputPath" and "RemoteCommand", but it's certainly not the complete set of properties that are displayed in the property pages where the "Enable unmanged code debugging" stuff can be found.)

    So maybe I'm working on the wrong set of properties? Any other ideas ?

    WM_THX
    -thomas woelfer


    http://www.die.de/blog

    Monday, February 24, 2014 10:54 AM
  • Hi,

    Yes, my syntax for properties was wrong, the correct one is:

    project = ...
    project.ConfigurationManager.ActiveConfiguration.Properties.Item("EnableUnmanagedDebugging").Value = true;
    

    Not all project types have the same set of properties at project level (EnvDTE.Project.Properties) and project configuration level (EnvDTE.Configuration.Properties), but I have tested it with a Windows Forms C# project in VS 2010 and the property exists and that code works.

    So, which VS version and which exact C# project type that has that setting at user interface level (Debug property page) is lacking that property at code level?


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    • Marked as answer by thomas_woelfer Tuesday, February 25, 2014 11:04 AM
    Monday, February 24, 2014 3:25 PM
  • Carlos,

    >> Properties.Item("EnableUnmanagedDebugging").

    Thank you. I really should have thought of this myself. Concerning the "Property not found" - this was just me being stupid. (The code to find the project I  was looking for was missing a ! ...)

    WM_THXALOT
    -thomas woelfer


    http://www.die.de/blog

    Tuesday, February 25, 2014 11:04 AM