I installed the dll to the GAC even updated the dll to install that into the GAC but I get this error:
"Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.":"Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"}
App.config
<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-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
GAC location:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Newtonsoft.Json\v4.0_12.0.0.0__30ad4fe6b2a6aeed\Newtonsoft.Json.dll
I also copied the dll to the C:\Windows\System32 but when I try to add it as a reference from this location visual studios doesn't see it.
Try using the ResolveEventHandler
delegate to load the .dll when an error is raised after it not being found. This can go directly above the Main()
method.
static ScriptMain()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.ToUpper().Contains("NEWTONSOFT"))
{
string path = @"C:\DLL File Path\";
return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Newtonsoft.Json.dll"));
}
return null;
}
public void Main()
{
...
To fix this issue I added a new script task and opened nugget from inside it.
I installed the Microsoft.AspNet.WebApi.Client package and then from this package added the System.Net.Http and Newtonsoft.Json dlls to my GAC.
After that I referenced those new dlls from the location it added them into and this fixed the issue.
This will only work if you are able to install the dll into the GAC on the server/computer running your SSIS package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With