Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly Microsoft.Win32.Primitives, Version=4.0.0.0

I am having problems running my web application.

The project setup is ASP.NET Core web application (.NET Framework). I don't seem to get any Build error. The project doesn't just run.

System.IO.FileLoadException: 'Could not load file or assembly 'Microsoft.Win32.Primitives, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

enter image description here

like image 693
Cody Avatar asked Feb 18 '17 06:02

Cody


3 Answers

Try adding the System.Net.Http nuget package.

like image 114
Tom Robinson Avatar answered Oct 11 '22 23:10

Tom Robinson


This happened to me after I had updated to Visual Studio 2017 15.4.5 and also updated a load of Nuget packages. I think part of the problem is also using .net framework 4.7.1 as well, which I installed last week...

The fix for me was to remove the dependent assembly from web.config, so just comment out or delete this section:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.Win32.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
like image 30
Liam Avatar answered Oct 11 '22 21:10

Liam


In other for me to get it working i uninstalled the Microsoft.Win32.Primitives then installed the exact version which is 4.0. this worked fir me.

Note that there are higher versions but they did not work for me.

like image 1
Cody Avatar answered Oct 11 '22 21:10

Cody