Reputation: 361
I am creating an extension to Visual Studio 2022. I have followed https://learn.microsoft.com/en-us/visualstudio/extensibility/creating-an-options-page?view=vs-2022 for adding options to the Tools Options property grid. In the experimental instance of Visual Studio, I can see the options and they persist (they are stored in a registry Hive in AppData if I understand correctly). According to that learning page, I can access the options in the OptionPageGrid instance (which is a DialogPage) by calling
OptionPageGrid page = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid));
However, when I do this, I always read the default values of the OptionPageGrid options, not the ones written and stored in the visual studio options grid. I can see the setters of the OptionPageGrid (DialogPage) options being hit in the debugger when the options page is opened in Visual Studio, but this appears to be a different instance of OpenPageGrid then the one retrieved by GetDialogPage. How do I access the options in the package?
If you are interested, the code in question can be found at https://github.com/harmenwierenga/Fortran_VS2022/tree/0b73646d1c0a0096a149c199b1116b6ee1992f48.
I have seen Visual Studio Extension: Access VS Options from arbitrary DLL, but this question is focused on accessing the options from other processes, which I do not think that I am doing. I have tried to use DTE objects, but I either got a null dte instance back (GetService) or I got a dte object (GetGlobalService) but then the program would hang when calling get_Properties on that object.
There is also Visual Studio Debugger Extension get user settings, but do I would prefer to use a stable API instead of hacking something that reads a path in the registry. Has that also changed? It appears that older versions of Visual Studio would write to the registry directly, but now the information is in AppData.
Upvotes: 2
Views: 444