References

Hi,

Im getting this error when attempting to load a web application

Could not load file or assembly ‘Microsoft.Extensions.Options, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Im referencing a specific version of Microsoft.Extensions.Caching.Memory [2.2.0] which has the above assembly as a reference and specifies

If I don’t add Microsoft.Extensions.Options as a direct reference then ebuild will always pick the greater version on the machine, in my case its 3.0.0

If you compare that to visual studio it always picks the lowest, ie 2.2.0

Im wondering if the version resolution is the source of my error at runtime ?

Cheers,
John

Possibility. Whats the full call stack fore the load error, and which other package pulls in the (newer) version of the ref, it you don’t hardcode it?

There is nothing else as far as I can see that’s using a later version in the solution. I seem to run into these issues whenever I end up with a new version on my machine. I think because I was testing something in isolation and added a newer version to a test project.
I fixed it by changing the version in the solution to the latest.

I had the same issue later on with another assembly

2019-10-16 11:47:08.6882|ERROR|Moshine.MessagePipeline.Pipeline|Error receiving messages|System.IO.FileLoadException: Could not load file or assembly ‘System.Diagnostics.DiagnosticSource, Version=4.6.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: ‘System.Diagnostics.DiagnosticSource, Version=4.6.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ —> System.IO.FileLoadException: Could not load file or assembly ‘System.Diagnostics.DiagnosticSource, Version=4.0.3.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: ‘System.Diagnostics.DiagnosticSource, Version=4.0.3.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’

=== Pre-bind state information ===
LOG: DisplayName = System.Diagnostics.DiagnosticSource, Version=4.0.3.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
(Fully-specified)
LOG: Appbase = file:///D:/develop/SailingLog/SailingLogSelfHosted/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.Azure.ServiceBus, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c.

I fixed that one by using a binding redirect. It was a bit of a nightmare because the nuget version didn’t match the assembly version.

I would prefer if the version resolution of references was different, so that it always picked the lowest. The way it is now seems a bit dangerous because the references in one solution is impacted by what I’m doing in another which seems wrong.