2

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.

reckface
  • 5,678
  • 4
  • 36
  • 62
  • Does `` include version 15.7.18 in the sense that 0 is a catch-all (I don't think this is the case)? Have you tried changing `newVersion` to `15.7.18` or `15.7.18.0` – Markus Deibel Jun 12 '18 at 09:49
  • @MarkusDeibel It didn't work because the problem is related to the version that Visual studio ships. – reckface Jun 12 '18 at 10:27
  • 3
    What worked was downgrading `Microsoft.VisualStudio.Threading` to 15.6.44, with binding redirect is `oldVersion="0.0.0.0-15.6.0.0" newVersion="15.6.0.0"`. Now I have **2** new IDE1002 warnings because of the Analyzer assemblies! How ironic. – reckface Jun 12 '18 at 10:29
  • For other's reference downgrading to 15.6.44 from 15.8.145 worked for me too – pensono Aug 29 '18 at 23:04
  • The commit [here](https://github.com/madskristensen/AutoLoadPackageManager/commit/cd56c81c982fba066144af3463f57369ae9b6dbd) from Mads implements the downgrade too. – Greg Trevellick Oct 25 '18 at 16:38
  • 1
    I had this after installing AWS toolkit. What worked for me was to install the latest updates for Visual Studio. – tgolisch Feb 16 '20 at 18:54

0 Answers0