I’m having a difficult time figuring out how to fix this issue. I’m trying to run a VS Studio 2015 SSIS Script Task with the Newtonsoft.Json.dll. I’ve tried adding it via GACUTIL, NUGET Package Manager, browsing/selecting assembly. No matter what I do, and no matter what version I tie too, it still gives me an error at runtime “Could not load file or assembly ‘Newtonsoft.Json, Version=6.0.0.0”. Here is my code which is basically a copy of other code snippets:
try
{
var clientId = Variables.User;
var clientSecret = Variables.Password;
var authenticationString = $"{clientId}:{clientSecret}";
//MessageBox.Show(authenticationString);
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString));
//MessageBox.Show(base64EncodedAuthenticationString);
string serviceUrl = "https://myapplication.com";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(serviceUrl);
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString);
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
string APIUrl = string.Format(serviceUrl + "/search-svc/datarequest/runReport?format=xml&report=USERNAME_LOOKUP");
var response = client.GetAsync(APIUrl).Result;
if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsAsync<HttpResponseMessage>().Result;
if (result.IsSuccessStatusCode)
{
//TODO update your database based on the result
}
//Dts.TaskResult = (int)ScriptResults.Success;
}
}
I installed version 13.0.3
This is the path to the DLL: C:WindowsMicrosoft.NETassemblyGAC_MSILNewtonsoft.Jsonv4.0_13.0.0.0__30ad4fe6b2a6aeedNewtonsoft.Json.dll
I updated the assembly binding to:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
I don’t know why it is looking for version 6.0.0.0 and how to change it.