1

I converted my console app to Class Library project so that I can use dll again for multiple project. I am getting an error

Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f711d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

I already tried the solution mentioned here Could not load file or assembly System.Net.Http.Primitives. Located assembly's manifest definition does not match the assembly reference.

But no luck. Any suggestion

Community
  • 1
  • 1
Ammar Khan
  • 346
  • 1
  • 9
  • 27
  • Take a [look](http://stackoverflow.com/questions/18370360/could-not-load-file-or-assembly-system-net-http-primitives-located-assemblys-m) here. – abhi Feb 26 '14 at 21:38
  • I already mentioned the same link in my question. Those solution not work for me. – Ammar Khan Feb 26 '14 at 21:40

3 Answers3

1

Try adding this to your web.config (or app.config):

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-2.2.18.0" newVersion="2.2.18.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
EkoostikMartin
  • 6,831
  • 2
  • 33
  • 62
  • Inside Class Library project or Win Form Project? I already tried that out by adding the above lines inside Class Library project but it does not work either. – Ammar Khan Feb 26 '14 at 21:23
  • Adding a config file to a class library does nothing, it needs to be added to the executable (Win Form in this case?) – EkoostikMartin Feb 26 '14 at 21:23
1

Try this:

  • Clean Project
  • Check if bin folder is empty, if not delete all files
  • Remove reference and add it again
  • Build project again

Cheers

tweellt
  • 2,171
  • 20
  • 28
1

What version of .NET are you using? If it is 4.0 or later can you check whether your library is set to use the Client framework or the full one. To check this you can right click on the project and select properties, it should then be on the first tab. Make sure it is set to the full framework not the Client framework.

Bijington
  • 3,661
  • 5
  • 35
  • 52
  • Yes, It is already set to Full Framework and I am running on the latest version 4.5 – Ammar Khan Feb 26 '14 at 21:29
  • From looking at the following question: http://stackoverflow.com/questions/215026/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference it looks like the .NET assembly loader is trying to find version 1.5.0.0 for the dll but it cannot find it. Is the Class Library being built on the same machine as the Console app? If so are you able to compare the paths for the bad reference on each project, either in the properties pane or in the csproj files by opening in a text editor? – Bijington Feb 26 '14 at 21:35
  • How can I get path for that specific assembly? – Ammar Khan Feb 26 '14 at 21:42
  • I don't find bad reference. In each of the csproj files, they are pointing to the correct location. – Ammar Khan Feb 26 '14 at 21:51
  • I turns out, it work fine inside console app when I reference a dll and put the config inside app.config. But it is not working in win form app. That's weird. Any idea? – Ammar Khan Feb 26 '14 at 21:56
  • When you checked the locations in each of the csproj files did it mention what version of the dll it wants? (I am assuming this should be 1.5.0.0) The easiest way to check this would be to select the reference in Visual Studio and press F4 to bring up the properties pane, then scroll down to the version section. Can you also check what the version of the dll in the correct location? – Bijington Feb 26 '14 at 22:03
  • Yes it is same for both project (i.e, 4.2.18.0) – Ammar Khan Feb 26 '14 at 22:07
  • Is the specific version flag in the properties set to true? If so it may be worth setting it to false and see if that fixes it. – Bijington Feb 26 '14 at 22:14
  • It is already set to false. None of the trick work for me. This is very behavior, it works inside console app when I reference my dll but getting an error in win form app. – Ammar Khan Feb 27 '14 at 08:02