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 ?
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’
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.