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

5

10

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

Ales answered 18/2, 2017 at 6:59 Comment(1)
See also: github.com/dotnet/sdk/issues/901Lawn
L
6

Try adding the System.Net.Http nuget package.

Lawn answered 25/4, 2017 at 13:52 Comment(0)
M
4

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>
Materse answered 30/11, 2017 at 7:5 Comment(0)
A
1

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.

Ales answered 18/2, 2017 at 12:39 Comment(2)
I had to add the System.Net.Http nuget package too, then it worked.Lawn
Just adding the nuget package System.Net.Http worked for me. @tjrobinson, consider adding that as an answer.Seneschal
D
0

I accidently deleted my *.suo files and the problem fixed itself. Maybe it was an accident, or irrelevant but i just thought to share it.

Dougdougal answered 29/4, 2018 at 15:22 Comment(0)
T
0

If you are targeting .Net 4.7.1 project, I contend that a 4.7.1 versioned Primitives DLL is not available. Take a look at the properties in Nugetenter image description here

I believe the Nuget expression would need a > not a = 4.6.

This feels like a hack, but it seemed to work. If you open Web.config, change this to 4.6enter image description here

Tantalize answered 20/8, 2018 at 23:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.