Could not load file or assembly 'NewtonSoft.Json, Version=12.0.0.0'

1

I'm new with C#. I'm using C# in SSIS Script Component.

I installed Newtonsoft.Json from References-->Manage Nuget Packages. I added using Newtonsoft.Json; in the namespaces as well. The script was building successfully with 0 errors but one warning, "There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Microsoft.SqlServer.DTSRuntimeWrap, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project."

If I execute, the package fails with the error, "Could not load file or assembly 'Newtonsoft.Json, Version=12.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)".

I tried removing the Newtonsoft.Json reference, and adding it manually from References-->Add Reference-->Browse-->Add Newtonsoft.Json.dll, but it also didn't help.

Also, tried, Solution-->Properties-->Configuration Properties-->Configuration Manager-->And then changing the platform to x86 of the project's debug and release configurations, still it didn't help.

Badly need some help. Thanks in Advance.

c#
.net
ssis
json.net
asked on Stack Overflow Feb 8, 2021 by Aritra Sarkar

1 Answer

0

you can map the newtonsoft assembly to the required version in app.config like below .

 <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>

User contributions licensed under CC BY-SA 3.0