Wumpf / IncludeToolbox

Visual Studio extension to format, prune, and inspect include directives.
https://marketplace.visualstudio.com/items?itemName=Wumpf.IncludeToolbox
MIT License
50 stars 22 forks source link

Missing Microsoft.VisualStudio.Threading dependency #73

Open pklima opened 4 years ago

pklima commented 4 years ago

IncludeToolbox 2.4.1 is failing to load for me in Visual Studio 2017 15.6.7.

After starting Visual Studio and opening a .cpp file the following error appears:

---------------------------
Microsoft Visual Studio
---------------------------
The 'IncludeToolboxPackage' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\Deadfast\AppData\Roaming\Microsoft\VisualStudio\15.0_3e853fc2\ActivityLog.xml'.

Restarting Visual Studio could help resolve this issue.

Continue to show this error message?
---------------------------
Yes   No   
---------------------------

The aforementioned log file contains the following error:

SetSite failed for package [IncludeToolboxPackage]Source: 'IncludeToolbox' Description: Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=15.8.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=15.8.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.VisualStudio.Threading, Version=15.8.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'at IncludeToolbox.IncludeToolboxPackage.InitializeAsync(CancellationToken cancellationToken, IProgress`1 progress)at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass16_0.<b__1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)at Microsoft.VisualStudio.Services.VsTask.GetResult() WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

To summarise the spam, it's trying and failing to load Microsoft.VisualStudio.Threading of version 15.8.0.0.

Looking at the extension files it doesn't actually ship any dependencies, perhaps it should?

pklima commented 4 years ago

I locally fixed this by including said dependency alongside the package but that just moved the problem elsewhere:

SetSite failed for package [IncludeToolboxPackage]Source: 'IncludeToolbox' Description: Method not found: 'Microsoft.VisualStudio.Threading.JoinableTaskFactory Microsoft.VisualStudio.Shell.ThreadHelper.get_JoinableTaskFactory()'. System.MissingMethodException: Method not found: 'Microsoft.VisualStudio.Threading.JoinableTaskFactory Microsoft.VisualStudio.Shell.ThreadHelper.get_JoinableTaskFactory()'. at IncludeToolbox.IncludeToolboxPackage.d6.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine) at IncludeToolbox.IncludeToolboxPackage.InitializeAsync(CancellationToken cancellationToken, IProgress`1 progress) at Microsoft.VisualStudio.Shell.AsyncPackage.<>cDisplayClass16_0.<b__1>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e) at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck) at Microsoft.VisualStudio.Services.VsTask.GetResult()

This seems to be a bug in the VS 2019 SDK: using JoinableTaskFactory.SwitchToMainThreadAsync() unintentionally introduces a Microsoft.VisualStudio.Threading 6.0.0.0 dependency.