FileLoadException after updating NuGet

After updating all of the NuGet packages, one of my applications started crashing on startup using FileLoadException :

 Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 

This was after upgrading ServiceLocation to version 1.3.0.0, and I double-checked all assemblies to make sure they were using this version. Then I ran Fuslogvw to diagnose the build, which was still referencing the old version:

 LOG: DisplayName = Microsoft.Practices.ServiceLocation, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Appbase = file:///C:/Users/Charlie/AppData/Local/Programs/MyClient/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = MyClient.exe Calling assembly : Microsoft.Practices.Prism.UnityExtensions, Version=5.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. === 

So, UnityExtensions (another NuGet package) still refers to the old version. But this should be good, because I added the bindingRedirect file to the app.config file:

 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.3.0.0" /> </dependentAssembly> </assemblyBinding> 

But that doesn't seem to matter. My application is for .NET Framework 4.5.1, and I tried it with AutoGenerateBindingRedirects incl. And off In other words, I literally tried everything. What's going on here?

+5
source share
4 answers

All you need to solve this problem is to update all PRISM and Unity related packages in all projects. Editing binding forwarding is not required.

Read more about codeplex

+1
source

You tried to change the binding redirection as follows:

 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> </dependentAssembly> </assemblyBinding> 

Please note that I only change the upper bound of oldVersion from 1.2.0.0 to 1.3.0.0 to catch any version to 1.3 and redirect it.

+1
source

Make sure that your links in the configuration files are actually used in the correct version. They may not be synchronized with the fact that NuGet is installed.

+1
source

This was not given in your example, but it can help others become like me.

Make sure you do not have the wrong set of .NET versions.

eg. appliesTo="v2.0.50727" will not work when using .NET 4 +

 <assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" /> </dependentAssembly> </assemblyBinding> 
+1
source

Source: https://habr.com/ru/post/1205139/


All Articles