Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Brien King
I currently have some ugly code that I use to get the IDesignerHost for Winforms, I'm wondering if there is a better way to get it?
Frank Naumann

What I am asking for is just a hint to the right approach to solve my task.
I have started to develop a VS extension to simplify the recurring implementation of state machines.
Creating an "Item Template Wizard" was no problem. It creates the folder structures , copies the default files and adjusts their contents, eliminates optional files if they are not needed. So far so good.

But for the further steps the approach of the "Item Template Wizard" seems to be not sufficient.
I want to be able to enter a list of states on the wizard dialog and add a file State.<Statusname>.cs to the project for each state.
Additionally the state should be added to the enumeration StatemachineX.States.cs and some special adjustments should be done in StatemachineX.Main.cs.

Of course, I want to reuse the code to add individual states during development. But that is a task for the future.

The following illustration shows the project part to be created:

+- ...
+- any other project files
+- ...
+- ...
+- any optional files // default files
+- ...
+- StatemachineX.States.cs // default file
+- StatemachineX.Events.cs // default file
+- State.Base.cs // default file
+- State.XXXX.xs // default file
+- State.X1 //
+- State.X2 // according to the states enumeration ...
+- State.X3 // defined by the developer
+- ... //
+- State.Xn //
+-StatemachineX.Main.cs // default file - main class of the state machine

If someone has the solution ... please don't tell (before I beg on my knees).
Links to solution approaches on the other hand ...


Hi everyone, I'm trying to get my extension ready for 2022 and I'm having issues with the settings manager.

I'm using Mads' BaseOptionModel. Everything worked fine in 2019, but in 2022 it's throwing in this line when trying to lazily create the AsyncLazy<ShellSettingsManager> _settingsManager.

The exception is a MissingMethodException claiming that ShellSettingsManager doesn't have a ctor that takes an IVsSettingsManager. But judging from the message, the exception acutally seems to relate to this line.

10 replies
Brien King
Does the Microsoft.VisualStudio.SDK not support class libraries?
Libraries are Framework 4.8
Brien King
When I try to add the Nuget Package Microsoft.VisualStudio.SDK it fails with "Could not install package 'Microsoft.ServiceHub.Analyzers 2.8.10'. You are trying to install this package into a project that targets ..."
Brien King
Well, I cheated and added a new VSIX project and will use that as the starting point for my Library. Apparently the Template will add the NuGet Packages, but it doesn't seem like you can add them to a normal Library project.
Brien King
Well, I have a rather annoying issue. This code:
        PropertyDescriptor propInfo = null;

        propInfo = TypeDescriptor.GetProperties(p_component)["Name"];
        propInfo.SetValue(p_component, p_newName);
fails in the Experimental Visual Studio (when debugging), but works just fine in Visual Studio if I install the Extension.
p_component is the new control I created via designerHost.CreateComponent
I take that back, p_component is an existing control I got from the designer host.
The error I get is:
Code generation for property 'FormatType' failed. Error was: 'Type 'Warp10.DeveloperExpress.Controls.EditControls.TextEdit+FormatTypes' is not available in the target framework.'
Brien King
Which is weird because that's not the control that I am renaming.
Aleksandr Danchenko
Hi everyone 👋, could someone know is it possible to set ToolWindow open by default? I mean if user install an extension and open VS it will see ToolWindow (without open it from View menu item). Something like Style = Microsoft.VisualStudio.Shell.VsDockStyle.Tabbed property. Thanks! 🙏
4 replies
Christopher Christou
Is it possible to start with an IVsHierarchy (x) for an arbitrarily selected item in the Solution Explorer and determine an IVsHierarchy (p) for the project that x belongs to? I'd like to understand how to do this without using EnvDTE. I've tried using GetProperty and __VSHPROPID.VSHPROPID_ParentHierarchy without success.
1 reply

Hey guys, I've implemented this before using reflecting and attributes, but I'm curious if someone has done something like this before.

Basically, anytime a class implements an interface, visual studio autogenerates a static "IFactoryGenerator" class, and appropriate overridden "Create" methods.

The crude way I did it before was, reflect over the codebase for any class tagged with "CreateFactory" attribute, and then generate a "IFactoryGenerator" static class, with pass through implementations.
Jialong Cheng
@kcbanner_twitter Sorry for the late response. I didn't get any notifications either.
Let me try to understand the problem: it appears that the dialog (part of the async task scheduled with search) showed up early enough with either "Normal Priority" or the UIthreadBackgroundPriority. The issue is actually that the WPF redraw of the search results is non-deterministic when using Dispatcher.Normal priority. Is that correct? If so, the problem lies in WPF redraw, not the task scheduling part.
If the above assumption was correct, do you mind sharing how your draw the search results on the UI?
1 reply
Hey guys
I've started creating my first visual studio extension, yet I have some problems with the databinding ("x:bind" or "{binding}") in xaml, does someone have a repo with an example using databinding in a visual studio extensions project?
I solved it, so for people who are also having trouble I used this example, turns out I cant use "x:bind" in xaml and should use that "DataContext" property of the toolwindow : https://github.com/madskristensen/SolutionExtensions/blob/61334eb283be2314f9df48a5dfcf64578e00a51e/src/ExtensionManager/InstallerDialog.xaml.cs
Tri-Edge AI
I am using BaseCodeGeneratorWithSite, but is there an async version of this somewhere? My GenerateCode logic takes 200-300ms and it creates a really annoying lagspike everytime I hit Ctrl+S while editing the file, which I do all the time instinctively.

VsixTesting allows you to easily create integration tests for your Visual Studio Extensions.

I just added support for Visual Studio 2022.

I've also created a pull request to properly initialize the Visual Studio Experimental Instance in the images used by GitHub Actions / Azure Pipelines to ensure that the integration tests execute very fast.

The fastest way to try this library is by cloning https://github.com/josetr/VsixTestingSamples which also has been updated to support Visual Studio 2022.

Sorry for the ad. My previous message about it was more than 2 years ago tho.

Neil Henderson
@josetr Thanks for your excellent work on this, it's a great tool!
Aleksandr Danchenko
Hi team 👋, could someone say is there any available Git API for Visual Studio extensions?
2 replies
And another question: what is the best way to track file changes in Visual Studio solution?
3 replies
@bluetarpmedia Thanks for the nice comment :thumbsup:
Christopher Long

Hi all, I've been having a go at making a VS extension however I'm totally new to .NET

I've got to the point where I can edit text in the active window using a command button, but what I would really like to do is highlight keywords in the active document in some fashion, like a squiggly underline or changing the colour of the font.

I've now hit a bit of a brick wall where I don't really know the terminology of what I should be searching for. Could anyone point me in the right direction of where I can start reading up on how to implement this sort of behaviour?

Many thanks

4 replies
Brien King
I need to get a Type from a class that is defined in a project that is a Winforms application (not an Assembly)? Any suggestions on what I would need to do to get a list?
Erik Ejlskov Jensen
Just a heads up - you CAN have a single codebase and extension project (depending on your API usage) for VS 2017, VS2019 and VS 2022 - Watch https://youtu.be/NWp8Nkp0V4k?t=2858 and feel free to ping me for additional info
פנינה בוזגלו
i have problem with load this site https://bignews.co.il/ , i need defined class to be separate from api useage, i will be happy for example
Robert van der Hulst
@BrienKing Have you tried Assembly.LoadFrom() or Mono.Cecil to load the EXE file ?
Robert van der Hulst
Robert van der Hulst
Is there a way to have my Visual Studio Extension create and push to a remote git-based (BitBucket) repository when the associated project template is initialized and without any user interaction? I couldn't find any service offering a method to connect the project to a repository or to invoke a push with the built in Git source control functionality. I know I could probably spin off a shell and run commands there, but that means the user of the template also has to have git installed instead of just using the build in Visual Studio -> Git functionality
Hi. I am developing an extension for a programming language. Is there a way to make Visual Studio does indentation for a new line after a left curly brace, like how it does for C# with smart indent?
@josetr thanks
I use StructureTag to get guide line and outline. I got the guide line but there is not outline. How do I get the outline for the structure?
This is the tag code in tagger GetTags method.
StructureTag tag;

tag = new StructureTag(snapshot, outliningSpan, headerSpan, null, null, PredefinedStructureTagTypes.Member, true);

yield return new TagSpanStructureTag(structureSpan, tag);
what would cause VisualStudioWorkspace.OpenDocument to not work? It doesn't throw any exceptions or anything, it just simply doesn't open the document...
I've also tried DTE2.OpenFile with the full path to the file (which is a member of a project, which is a member of the opened solution) and that also does nothing.
cool, VsShellUtilities.OpenDocument also does absolutely nothing. what gives?
I've tried force-saving the solution and all projects before calling OpenDocument, I've tried adding an await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync() directly beforehand (even though I'm already on the UI thread), I've even tried looping 10 times with a 1-second delay between tries to see if it's some timing thing, and absolutely nothing happens. the workspace just sits there with no document open. I can copy the exact file path it's trying to open and use Ctrl+O to open it manually, and it opens the file as a member of the current solution (not a "miscellaneous file" or whatever), so it's definitely in the solution as a compilation unit. that shouldn't matter; I'd expect it to open any document you give it. It's just totally unresponsive.
Indu Prakash
2 replies
Any idea how one can adjust the "No issues found" message at t he left-bottom of the document.
Vyacheslav Avdeev
@ArcanoxDragon I guess you can start from a new, empty, vsix and try to open something. if it successed, then copy stuff from your vsix to the new and check if opening works... and so on. no other ideas...
Jakub Míšek

Hello; does anybody know if there's currently some issue with icons in Project Hierarchy on VS 2022 Preview 3,4,5?

We're providing ImageManifest with both xaml and png (16x16) icons; they load and show well in project and item templates. However since DEV17 preview 3 they are not showing (just a blank space is displayed instead) in the project hierarchy (both in CPS extended with IProjectTreePropertiesProvider, and in old MPF where we provide IconMoniker through VSHPROPID_IconMoniker** properties)

Thank you for any hints.


Anyone knows how to make projection buffers to work in VS 2022?

I reported this problem on Developer Community in August, but no answer so far:

1 reply