Simon
Simon

Reputation: 1333

Losing Newtonsoft reference when closing script task in SSIS

I am building an SSIS package in Visual Studio 2012 and in the package I have a C# script task that reads in a variety of file formats and inserts data from those files into a database table.

This works fine, but now I need the script to handle JSON.

To do this I have gone into the script task and added the Json.NET framework via the NuGet Package Manager and then added the following line of code to reference the namespace.

using Newtonsoft.Json;

I can then reference the library and use commands such as JsonConvert etc. but when I save the script and close it in order to run the SSIS package I get the following error:

Error: 0x1 at SCR - Populate Landing Table, Error in script: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

When I go back into the script the reference to the namespace has a red squiggly line underneath

enter image description here

and when I go to the NuGet Package Manager there is a message saying Some NuGet Packages are missing from the solution.

enter image description here

Restoring doesn't fix the problem, I have to uninstall and reinstall Json.NET to get rid of the red lines, but then the process starts again when I close the script and try to run the package.

Any help as always is greatly appreciated.

Thanks

Upvotes: 2

Views: 3515

Answers (1)

Jamy Pad
Jamy Pad

Reputation: 46

You have to add the library to the Global Assembly Cache (GAC)

  1. After installing the reference, go to the reference on the solution.
  2. Right click and go to Propterties.
  3. Copy the physical route example C:/... etc.
  4. Go to VS code cmd and open as administrator.
  5. Type gacutil -i followed by the PhysicalRoute, (you can paste it)

example:

gacutil -i C:/Solution/... 

it will give a message that the library was succesfully added to the GAC then it won't dissapear anymore.

Upvotes: 0

Related Questions