I have written a VSIX that fails in VS 2017
System.IO.FileNotFoundException: Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.4.0
Yet the csproj includes the package for that assembly
<PackageReference Include="System.Numerics.Vectors">
<Version>4.5.0</Version>
</PackageReference>
and I have verified that System.Numerics.Vectors, Version=4.1.4.0 lands in the extensions folder:
C:UsersIEUserAppDataLocalMicrosoftVisualStudio15.0_90a627f6Extensionsj5lca0pj.xmg
I checked fuslogvw
and get
*** Assembly Binder Log Entry (4/6/2023 @ 9:19:29 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:WindowsMicrosoft.NETFrameworkv4.0.30319clr.dll
Running under executable C:Program Files (x86)Microsoft Visual Studio2017CommunityCommon7IDEdevenv.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:UsersIEUserAppDataLocalMicrosoftVisualStudio15.0_90a627f6devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config.
LOG: Post-policy reference: System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TestWindow/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TestWindow/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Numerics.Vectors/System.Numerics.Vectors.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TestWindow/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TestWindow/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Numerics.Vectors.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Numerics.Vectors/System.Numerics.Vectors.EXE.
LOG: All probing URLs attempted and failed.
Although I am directly including the System.Numerics.Vectors package it is not used directly by the VSIX but is instead a reference of System.Memory, unsure if that should matter.
I also notice that for other package references that are found, the last line in the fusion log is it looking in the extension folder, so why isn’t it looking there for Numerics.Vectors?
Eg.
LOG: Attempting download of new URL file:///c:/users/ieuser/appdata/local/microsoft/visualstudio/15.0_90a627f6/extensions/j5lca0pj.xmg/GA4-NET.DLL.
LOG: Assembly download was successful. Attempting setup of file: c:usersieuserappdatalocalmicrosoftvisualstudio15.0_90a627f6extensionsj5lca0pj.xmgGA4-NET.dll
devenv.exe.config
contains no mention of System.Numerics.Vectors, so there is no redirect.
UPDATE: I found that the problem has gone away by removing these binding redirects and downgrading my package reference to System.Runtime.CompilerServices.Unsafe
from 5 to 4.5.
[assembly: Microsoft.VisualStudio.Shell.ProvideBindingRedirection(AssemblyName = "System.Memory", OldVersionLowerBound = "1.0.0.0", OldVersionUpperBound = "4.0.1.1", NewVersion = "4.0.1.2")]
[assembly: Microsoft.VisualStudio.Shell.ProvideBindingRedirection(AssemblyName = "System.Runtime.CompilerServices.Unsafe", OldVersionLowerBound = "1.0.0.0", OldVersionUpperBound = "4.0.4.9", NewVersion = "5.0.0.0")]
[assembly: Microsoft.VisualStudio.Shell.ProvideBindingRedirection(AssemblyName = "System.Numerics.Vectors", OldVersionLowerBound = "1.0.0.0", OldVersionUpperBound = "4.1.3.0", NewVersion = "4.1.4.0")]
In the process I found that when I removed the redirect to System.Numerics.Vectors
then it stopped complaining about not finding that and instead complained about not being able to find System.Memory
. And there is a reference, System.Memory -> System.Numerics.Vectors
. I haven’t had time to really think about it but clearly the redirects are affecting how it finds assemblies. I’m past this now.
2
Answers
I believe I have figured it out.
(At least in the context of a VSIX, maybe in general) let's say you have a reference to assembly A v1 which has a reference to B v1.
But for whatever reason you need to redirect A to v2, and
so you put a binding redir in your project
A v1 to A v2
. Even if B v2 is distributed with your project it seems that the assembly binder loses context and will not look for B v2 in the same directory as MyProj is in - whereas without the redirect it would have look in the MyProj dir.The error states that it is unable to locate version 4.1.4.0 of the assembly System.Numerics.Vectors and you have installed/referenced version 4.5.4.0.
You will need to add an assembly binding redirect to your web.config.