I am writing an Add-in for Visual Studio 2017. I use the following:
Dispatcher.CurrentDispatcher.Invoke(()=>
{
// ...
});
But I keep getting the compiler warning: VSTHRD001 Avoid legacy thread switching methods
and since I can be a bit obsessive, I researched the warning, and applied the "fix":
ThreadHelper.JoinableTaskFactory.Run(()=>
{
// ...
});
Since applying the fix, the method won't even run, upon further investigation, it's throwing the error: 'Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=15.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
I'm using the nuget package <package id="Microsoft.VisualStudio.Threading" version="15.7.18" targetFramework="net461" />
and I have the binding redirects from installing the package in my app.config: <bindingRedirect oldVersion="0.0.0.0-15.7.0.0" newVersion="15.7.0.0" />
I've downgraded the package and even tried changing the redirect version but to no avail. For the only other similar related issue, Microsoft insists it's not a bug.
I'm using Visual studio 15.7.3 and that dll in the C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PrivateAssemblies is version 15.6.27-beta+gca...
Any ideas? Yes Dispatcher.CurrentDispatcher.Invoke
works perfect.