REST interface // Newtonsoft.Json.dll // Problem with System.Net.Http

Markus Freitag 3,791 Reputation points
2023-10-12T18:53:02.76+00:00

Hello,

System.Net.Http.Formatting

Newtonsoft.Json.dll

NuGet\Install-Package Newtonsoft.Json -Version 6.0.1

https://www.nuget.org/packages/Newtonsoft.Json/

Messages
//Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0'
//A dependency on it was not found. The found manifest definition of the assembly does not match the assembly reference.

//System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or 
//one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


//Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral

// I needed for a REST interface.
 response = client.PostAsJsonAsync(urlParameters, p).Result;
 

I use these two files. Updated on the version 12.0.0 at Newtonsoft.Json.dll

Now I get the error message. Where do I get the correct System.Net.Http.Formatting file?

I suspect this file uses the 6.0.0 and gives a version conflict.

Which tool can I use to see which dlls the current dll contains?

What is the best way to solve it? A Dll does not load a config file, isn't?

Thanks.

/////////// Please note I found this on the net. I use this in my own DLL. I have no App.Config, no Package Config. Or maybe is it possible inside a setting file? But how and who reads the values?

  app.config 
      <dependentAssembly>
          <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-9.0.1" newVersion="12.0.1" />
      </dependentAssembly

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Newtonsoft.Json" version="6.0.1" targetFramework="net472" />
  <package id="System.Net.Http" version="2.0.20126.16343" targetFramework="net472" />
  <package id="System.Net.Http.Formatting.Extension" version="5.2.3.0" targetFramework="net472" />
</packages>

Developer technologies C++
Developer technologies ASP.NET Other
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-10-12T22:18:27.7266667+00:00

    the nuget package System.Net.Http.Formatting was deprecated and removed from nuget for security issues. It should not be used. a replacement is:

    Microsoft.AspNet.WebApi.Client

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.