Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileLoadException after NuGet Update

After doing an update of all NuGet packages, one of my applications began crashing on start-up with a 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 ensure that they were using that version. I then ran Fuslogvw to diagnose the assembly that 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) is still referencing the old version. But that should be OK, because I've added a bindingRedirect to my 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 this seems to make no difference. My application is targeting .NET Framework 4.5.1, and I've tried it with AutoGenerateBindingRedirects on and off. In other words, I've tried literally everything. What is going on here?

like image 563
Charlie Avatar asked Sep 29 '22 14:09

Charlie


1 Answers

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

See details on codeplex

like image 82
Alex Erygin Avatar answered Oct 07 '22 21:10

Alex Erygin