1

How do I programmatically set and unset Visual Studio Options?

enter image description here

I have done the research and troubleshooting and apparently it is not possible.

Here is a question I answered specifying why it's not possible to programmatically click buttons in the VS Options Dialog: Programmatically reset VisualStudio shortcuts.

I don't need to click a button, I need to change a boolean setting as per the screenshot.

Might there be any undocumented methods I can use?

halfer
  • 19,824
  • 17
  • 99
  • 186
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321

2 Answers2

4

Just use:

dte.Properties["Debugging", "General"].Item("EnableExceptionAssistant").Value=false;

Most of the options can be retrieved and set this way. See also:

Options Page, Debugging Node Properties

HOWTO: Getting properties from the DTE.Properties collection of Visual Studio .NET.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Peter Macej
  • 4,831
  • 22
  • 49
2

You'd have to write code to change the following registry key.

HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\ApplicationPrivateSettings\_metadata\revisions\Microsoft\VisualStudio\Platform

TitleCaseMenus is the node you're after :)

You may need to change the Visual Studio version number depending on what you have installed.

Edit: For your new pic the registry key is here: HKCU\SOFTWARE\Microsoft\VisualStudio\14.0\Debugger\UseExcept‌​ionHelper

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Ryan Thomas
  • 1,724
  • 2
  • 14
  • 27
  • Does that change the setting while debugging? or does Stop/Start or F5/F6 make VS re-read the setting? How did you work this out, ProcMon? – Jeremy Thompson Nov 10 '16 at 11:20
  • Can't say I've tried. I imagine it would require a restart of Visual Studio for this change anyway. Sorry isn't the most detailed anwser ever, just wanted to give you a starting point. I'll see if I can find more. To find this I had some notes on a Visual Studio error message which I needed to unsupress previously which was a regfix and then searched through the registry. All the settings are there somewhere just hard to find. Not sure how you'll get it to apply without re-opening VS. – Ryan Thomas Nov 10 '16 at 11:22
  • ExceptionAssistant appears to have it's own bit. Mine is enabled and I have. HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0_Config\ExceptionAssistant which then has KnownEngines underneath it, do you have this with it disabled? Can't seem to find an Enable anywhere for it :( – Ryan Thomas Nov 10 '16 at 11:33
  • Maybe that's it, I need to hack the memory address of that option.. to change it in run-time – Jeremy Thompson Nov 10 '16 at 11:33
  • Think I found it. Try HKCU\SOFTWARE\Microsoft\VisualStudio\14.0\Debugger\UseExceptionHelper just tested it using VS and can see registry change :) – Ryan Thomas Nov 10 '16 at 11:37
  • I found it in Process Monitor, all be it, it took a while and a lot of filtering. Great program but can be very difficult to find specific things, sure you would of found it eventually. No worries and thank you :) – Ryan Thomas Nov 10 '16 at 11:41
  • Just a question, I didn't test. If you change the mentioned registry value, will it be reflected in already opened Visual Studio? Moreover, if you then close VS, won't the VS re-write the value in registry? – Peter Macej Nov 10 '16 at 12:59
  • Not sure, mentioned above you may need to re-open visual studio. It wouldn't get overwritten over when you write over no as it's read, it will only get overwritten when you press OK to change it. Wasn't aware of your method to change it, but seemse much cleaner. :) – Ryan Thomas Nov 10 '16 at 13:34