Could not load file or assembly 'Newtonsoft.Json' Version=11.0.0.0
Asked Answered
T

8

22

I have read a lot of the responses to previous versions of this issue but none seem to work.

Every time I open my script component in Visual Studio 2015 (v14.0.25431.01 update 3) it tells me I am missing a reference to Newtonsoft.Json. So I go into NuGet Package manager and it asks me to Restore which I do and says it completes successfully.

I then save and try and run my SSIS package and get the following error.

Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependancies. The system cannot find the file specified.

my packages.config file looks like this.

    <?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Newtonsoft.Json" version="11.0.1" targetFramework="net45" />
</packages>

and my app.config file looks like this.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
      <assemblyIdentity name="Newtonsoft.Json"
                publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

I can navigate to the folder that it is looking for and see the .dll file

C:\Users\lp1.db\AppData\Local\Temp\Vsta\SSIS_SC130\VstaGbmf__V5kCUWonnRT2qrG_g\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll

Has anyone else had this continual issue with it losing the ability to find the file despite being set.

Taritariff answered 5/3, 2018 at 1:38 Comment(2)
@Hadi I'm not sure removing the visual studio tag as you did is correct here. Are you sure this is not related to visual studio (or possibly nuget)?Wheeling
I think the problem is if your project is NET 4.6.2 you should use version 9.0.1 max. If you want to use the later ones you should upgrade your project to NET 4.7.2 - I think it is something to do with NET STANDARD 1.6 to 2.0 transitions.Karame
N
8

Remove all the references to Newtonsoft.Json in all your projects.

Go to Nuget Package Manager (right click on solution), download Newtonsoft.Json latest version and select all the projects to use it, and reinstall it.

Make sure the packages.config have the latest version:

<packages>
  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
</packages>

Rebuild solution.

Navarro answered 10/7, 2018 at 18:54 Comment(0)
P
3

This is one of the most common problems in .NET projects. Basically someone made a reference directly to an local assembly instead of managing the package via NuGet or the project was made to compile in a different .NET version. The best way to solve this is to locate the reference in your project references, remove it, clean the project, check if the DLL has gone and finally remake the reference using NuGet.

Paradiddle answered 10/7, 2018 at 19:18 Comment(0)
U
1

Try to copy NewtonSoft.Json to the SQL SSIS Runtime folder

C:\Program Files (x86)\Microsoft SQL Server\[SQL Server version]\DTS\Binn

example (SQL Server 2016)

C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn
Undeceive answered 5/3, 2018 at 3:17 Comment(1)
Try to copy the dll file to an external folder. Delete the reference and add it again from this folderUndeceive
E
1

Try clean your project.

Clean Project in Visual Studio

If this don't work, remove the reference under references. Save the dll file in your bin folder and then add it again. Browse your file, select it and click in ok.

Edema answered 5/3, 2018 at 21:3 Comment(0)
A
0

I had a similar issue when I had two different projects within the same solution, in which one of them is referring to version 11.0.2 and the other is referring to version 6.0.4. If this is the case, try keeping the same version for both of them and retry.

Amr answered 20/11, 2018 at 9:58 Comment(0)
F
0

The best answer is here: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies

    public static void SetBindingRedirect()
    {
        AppDomain currentDomain = AppDomain.CurrentDomain;
        currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler);
    }

    private static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args)
    {
        if (args.Name.Contains("Newtonsoft.Json"))
        {
            string assemblyFileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Newtonsoft.Json.dll";
            return Assembly.LoadFrom(assemblyFileName);
        }
        else
            return null;
    }
Fronde answered 19/5, 2020 at 16:49 Comment(0)
B
0

copy paste Newtonsoft.Json.dll and Newtonsoft.Json.xml available in your build/release or build/debug to deployed ProjectFolder

Borden answered 3/4, 2021 at 6:24 Comment(0)
H
0

I forced an uninstall of newtonsoft.json from version 13 something (you have to go into the settings inside the NuGet window of the plugin). I then got tons of errors and just reinstalled it again. All the errors went away, I reran the program, and this time it passed the version error.

Hangdog answered 5/12, 2022 at 9:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.