Reproducing Newtonsoft.Json build version conflict

I decided to consistently reproduce the build version conflict in Newtonsoft.Json (related to my previous question Why is Newtonsoft.Json so prone to build version conflicts? ) In order to better understand this, but I cannot run it.

From the top answer there, this should happen if I have a project A that references one version of Json.NET, then it refers to a project B that itself references another version (and they don't have assembly redirects to handle the release).

I made a decision with the class library project and the command line project, both of which reference Newtonsoft.Json, which I installed with Nuget Package Manager for both projects, and then I edited the packages.config class library to use the older version:

<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net452" />

While the command line project is referencing the latest version:

<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />

This does not cause a problem, but the project is still successfully building and executing (I just serialize the string and print it from both projects, and I call the DLL from the EXE to make sure that it is trying to load both versions of Newtonsoft.Json.

I downloaded the test project https://github.com/sashoalm/ReproduceNewtonsoftJsonBug , if necessary.

Why does the error not work?

+4
1

-, , packages.json - 6, 10:

<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>

, (, ), . , , . :

Visual Studio 2013, , .NET Framework 4.5.1 . , config (app.config).

ConsoleApp5.exe.config ( app.config Visual Studio, Debug\Release) - , :

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

, exe - .

.csproj. .csproj, PropertyGroup s:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

true false - , .

+4

Source: https://habr.com/ru/post/1679803/


All Articles