Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Chris Varone
Hello all, I'm having a real compatibility issue. I'm developing in VS2019 and I need things to work in VS2017.
 private async Task LoadDataGridAsync()
                // if we are not executing in the main thread then we need to go to the main thread and alter the UI so we can update the data grid. 
                if (thisControl.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
                    await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
When I have this API in my code VS2017 just has a conniption.
The SwitchToMainThreadAsync()
I need a way to get to the main thread an modify the GUI.
Chris Varone
SO experimentation so far has shown that a synchronous command to update the GUI thread seems to be the only way to get this to work.
i.e. ThreadHelper.Generic.BeginInvoke(() =>
what do you mean "just has a conniption"?
Chris Varone
well the debugger spits out that the visual studio DLL's thrown a repeating exception. and the thread never get's executed. but nothing visually happens on visual studio and the GUI does not update. it basically attempts to launch the thread but having the call to SwitchToMainThreadAsync() makes the whole thing asnync function seem to abort. Debugger never hits a single line of code within the function when when calling it directly and synchronously
This seems to be some sort of compability issue with the VisualStudio.threading.dll beteen VS2017 and VS2019
if I await on the function I never reach a breakpoint with the function either. Just to clarify
Andy Hippo
@vasantha-kumar25 I need to refresh my knowledge about all the hacks I had to do :) I'll take a look later this week and get back to you
Neil Henderson
@Vero1010110_twitter I think you need to do two things. First, change your Microsoft.VisualStudio.Threading nuget package to the very latest 15.x version (Maor Version 15 = VS 2017), if it's not already. That will work in both 2017 and 2019. Second, you don't need the if (thread != current thread) stuff. The call to SwitchToMainThreadAsync is very cheap, so just do it whenever you need to be on the main thread. Don't use any of the BeginInvoke stuff. For more info, see this: https://github.com/microsoft/vs-threading/blob/main/doc/cookbook_vs.md
Yann Duran
@bluetarpmedia I was just reading down the the thread and was about to advise the same link, but then I saw you had beaten me to it :-)
Nikolay Mishev
Hi guys,
Can some one tell me if it is possible to open VS 2019 Create new project window from a commandline with opening specific templates. Currently we are using this command that works for VS2017(and older) devenv.exe /command "File.SelectProjectTemplate ^"<someTemplateName>^" N/A"" but this seems not to work for VS 2019 and I cannot find how to open the Create new project window with some specification either some search or the "language" "platform" "projectType" options?
Yann Duran

@NikolayMishev my guess is that when they redesigned the "New Project" dialog they think about it being used that way. it's been a common pattern - they replace something that works with "something new", and that something new doesn't have all of the previous functionality.

i suggest you add an issue using the "Report a Problem" (or Feedback) button in the top right of VS. that's supposedly the quickest way to get something looked at. even the VS team members who sometime hang out here will ask you to do that, before they can try to help


Hi all, I'm trying to update one of our VS extensions and I'm getting

Install-Package : Could not install package 'Microsoft.ServiceHub.Analyzers 2.7.2466'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does 
not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Microsoft.ServiceHub.Analyzers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

However, the package doesn't say it requires any particular version of the .NET Framework. What am I missing?

2 replies
Hi all,
My company ported a VS2013 extension for VS2019 and moved from C++ to C#, which is nice, but the new extension is a bit of a mess. I'm working on a work-around where I Uninstall/Disable the extension and supply new .targets/.xml files for the filetypes the extension managed. This seems promising.
BUT, I need to disable/uninstall the extension. Is there a way a project file or properties sheet can disable an enabled VSIX extension?
There is a case where the Extension trapped a build event and launched a second pass build. This case I will still require the extension to be enabled. So some projects in the solution will want the extension disabled, and some will not. Essentially I want build events from some projects not to be seen by the Extension.
At the moment the only way I see to do this would be to manually disable the Extension... Run the projects in the solution that work without it, then Enable the Extension and run the one case that may need it.
I'm looking into a way for MSBUILD to create two separate targets which will eliminate the two pass requirement but My MSBUILD-FU and even after I solve this, some projects may still want the extension and others not.
I'd rather not have to teach all my users how to turn on/off the extension and would like to automate that somehow.
We do have a disable flag or our extension, but one of the bugs is that it is not looking at flags for a multi project solution so it's broken.
Neil Henderson

We do have a disable flag or our extension, but one of the bugs is that it is not looking at flags for a multi project solution so it's broken.

I think this is where you should focus your efforts. Instead of disabling/enabling the VSIX extension in VS, it sounds better to use an internal flag to control whether your functionality is enabled or not.

Dan Vyskrebets
Hi everyone. I'm working on ssms extensions using vs sdk. Right now, I'm trying to open new tab using vs sdk.
When you just open ssms and click that 'new query' button, new window opens, but it's not tied to the specific file or something else. It's just new tab with opened editor that you can save as a file. I'm trying to do the same. Any help how can I do that ? The closest thing I came up with is using IVsUIShellOpenDocument interface, but it's not clear to me how exactly I can use it for my purpose. Thanks anyway.
I invoke "Find in Files" searches from my Extension, but with the modernization in Visual Studio 2019 16.9.5 (https://devblogs.microsoft.com/visualstudio/modernizing-find-in-files), my Extension seems to still be using the old methods and not the new functionality. Does anyone know how I would go about updating my Extension to use it? I can't find any information anywhere but it appears that others have figured it out with some extensions like "Multiline Search and Replace". What I use now is what is exposed by EnvDTE80.DTE2.Find
1 reply

Hi All, I have recently deployed the Extension to the target machine, using a custom installer instead of vsix. The Custom installer will Copy the extension to Common7\Ide\Extensions\OurProduct subfolder inside VS and then run denenv with the /updateconfiguration command line option so it can detect our extension.

The Installation is successful and The extension is working as expected. However, post installation, when the developer tries to Build the source code of the Extension, which in turn, deploy the vsix content to the experimental instance, any one of the below build errors are thrown.

1) The 'UninstallExtension' task failed unexpectedly
2) Extension '<productID> is of the same or lower version than the installed extension. Please make sure that the extension version is higher than that of the installed extension

Getting these error is general behaviour of VSIX ? Or Am I Missing any item? Any insight on why this occurs and how we can handle them? @RobertvanderHulst

James Vango
Hey! I don't know if this is the right place to ask about this but I am having some real issues with a package I am developing. Everything was working beautifully, until I added a reference to Microsoft.VisualStudio.VCCodeModel to the project. Now none of my breakpoints hit. Does anyone know what could be going on and how I can fix it? I have been trying for a while to get it sorted!
There seems to be an issue with the latest Microsoft.VisualStudio.SDK I am getting "Could not install package 'Microsoft.ServiceHub.Analyzers 2.7.345'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2','." which is odd because the SDK requires 4.7.2 and it won't install on any other framework. So it's impossible to install it at all.
If I install the older version 16.0.206 it works fine
Robert van der Hulst
@vasantha-kumar25 During developent we always make sure that the version that we are debugging has a higher version number than the one that is installed. That way it will automatically replace the installed version when running in the experimental hive.
1 reply
Christopher Christou
Does anyone have xunit tests that exercise code that calls ThreadHelper.ThrowIfNotOnUIThread()? I'm not having consistent success in this space, and would be interested in hearing what others have set up for this.

Hi everyone, I don't usually use this platform, sorry if I do something wrong.

I'm trying to develop an extension that attacks visual studio build events.

My goal is, in the compilation event.

  1. Let the application compile.
  2. MODIFY x values ​​of the compiled application and replace it (in bin / release)
  3. Let him continue his march, that is, do deploy, do a nuget pack, whatever he should do.

I am using the build events from the DTE, exactly OnBuildProjConfigDone.

If I execute my point 2 there. It works, the problem is:

If I do it asynchronous:

public void BuildEvents_OnBuildProjConfigDone (string projectName, string projectConfig, string platform, string solutionConfig, bool success) { JoinableTaskFactory.RunAsync (async delegate { .... the code

Process 2. is executed asynchronously, that is, the compilation process would go to:

  1. Compile
  2. Does what it has to do
  3. Run my custom task (async).

If I don't do async, JoinableTaskFactory.Run, the Visual Studio interface hangs for several minutes until point 2 ends.

Is there a way to get the flow I need?

The specific question is, how can I make an event that does not freeze VS (aysnc, but that build stops until my process finishes) and is executed as soon as the application is compiled (before doing pack, deploy, build an apk if it is xamarin etc).
The code is https://github.com/dotnetsafer/Shield.VSIX/blob/master/ShieldVSExtensionPackage.cs#L296, that works, but of course it doesn't follow the flow.
If for example you do pack,
  1. Compile, 2. Pack. 3 Own function
    But the packaging does not contain the custom function.
Sajal Verma
It seems that not all UICONTEXT visibility constraints are recognized by .vsct files. I was able to set UICONTEXT_SolutionExists as a constraint and my command is only visible when solution exists in Visual Studio, but UICONTEXT_SolutionExistsAndFullyLoaded gives me a compilation error: Undefined 'context' attribute 'UICONTEXT_SolutionExistsAndFullyLoaded' in a <VisibilityItem> element.
Sajal Verma
The same UICONTEXT works when set on my VSPackage as a ProvideAutoLoad attribute, but not on a command in my VSPackage. The command is a context menu button for Solution Explorer items . Is there no way but to define a custom rule and set it active/inactive using SVSMoniterSelection service to mimic the UICONTEXT_SolutionExistsAndFullyLoaded?
Hi everyone,
I need to display a custom glyph next to the debug breakpoint as in below image. I couldn't find a clear documentation on this area. Very much appreciate if you can point me to any references on addressing this.
Matt Lacey
Does anyone know if it's possible to detect dragging and dropping from the toolbox in an editor extension? I have an IDropHandlerProviderthat allows me to handle drops from the Solution Explorer (via "CF_VSSTGPROJECTITEMS") but I can't find a DropFormat for items from the Toolbox. I assume it's a custom format (& identifier) but I don't know how to find it.
Alexander Gayko

i was just fixing a bug in my extension and it's not building in azure devops anymore:
they seem to have changed the default build machine... again... any hints?
here's the error:

C:\Users\VssAdministrator.nuget\packages\microsoft.vssdk.buildtools\16.10.10\tools\VSSDK\bin\VsixUtil.exe package -sourceManifest "obj\Release\extension.vsixmanifest" -outputPath "bin\Release\VSWinExplorerWindow.vsix" -files "obj\Release\files.json" -compressionLevel "Normal"
VSWinExplorerWindow -> D:\a\9\s\VsVarAdornment\VSWinExplorerWindow\bin\Release\VSWinExplorerWindow.vsix

[error]C:\Users\VssAdministrator.nuget\packages\microsoft.vssdk.buildtools\16.10.10\tools\VSSDK\Microsoft.VsSDK.targets(787,5): Error MSB4018: The "GetDeploymentPathFromVsixManifest" task failed unexpectedly.

System.TypeLoadException: Method 'get_JoinableTaskFactory' in type 'Microsoft.VisualStudio.Sdk.BuildTasks.ExtensionEngineHost' from assembly 'Microsoft.VisualStudio.Sdk.BuildTasks.16.0, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation.
at Microsoft.VisualStudio.Sdk.BuildTasks.ExtensionManagerUtilities.GetExtensionEngine(ISettingsManager manager, Boolean deletePendingUninstalls)
at Microsoft.VisualStudio.Sdk.BuildTasks.GetDeploymentPathFromVsixManifest.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Indu Prakash

Is it possible to adjust the title of the window created when a document is dragged out?

I attempted adjusting the frame caption in IVsRunningDocTableEvents3.OnBeforeDocumentWindowShow but it always fails.

pFrame.SetProperty((int)__VSFPROPID.VSFPROPID_Caption, "@ " + Path.GetFileName(path));
Alexander Gayko
hey, has anyone else noticed that a lot of extensions aren't available in the marketplace lately?
Yann Duran
@AdmiralSnyder you should be able to specifiy the build machine's OS in your yaml file
Alexander Gayko
@yannduran i have, i think. it wasn't changed. something in the machine must have changed somehow...
... or it wasn't automatically moved to the newest VS build? is that a possibility?
Yann Duran
@AdmiralSnyder sorry I'm no expert, so I'm not sure what else to suggest
Is anyone familiar with the Razor/cshtml editor in VS? I'm wanting to know how VS knows whether it should open .cshtml files using the older Razor editor for ASP.NET MVC 4-5 with support for @helper syntax vs. the newer Razor editor for ASP.NET Core which does not support the @helper syntax.
(Backstory: I'm the maintainer of RazorGenerator, and I want to know how I can force VS open .cshtml files used by RazorGenerator using the older editor so it stops giving design-time build errors due to the use of @helper etc)
@Jehoel best to ask that question over at dotnet/roslyn
@CyrusNajmabadi the GitHub repo or on Gitter?
my question isn't concerned with Roslyn though... just how VS' editor extensibility works, so I'm curious why you're recommending the Roslyn community
the github repo. thanks!
my question isn't concerned with Roslyn though... just how VS' editor extensibility works, so I'm curious why you're recommending the Roslyn community
that's a fair poin, and perhaps this is the right channel
the reason i recommend Roslyn though is that Roslyn includes the razor editor team
so i presumed we (i'm on that team) would know the best about how this works :)