问题
I'm writing C# code in a script task in SSIS. I need to use the Newtonsoft JSON package in the code so i have installed it from NuGet. When it is first installed it works fine, but when I close my code and re-open it to make a change, I have to re-install the package using update-package -Reinstall
as per the Some NuGet packages are missing from the solution in Visual Studio Application post.
Why do I have to do this every time? Am I doing something wrong?
Thanks for your help.
回答1:
I found that adding the assembly to the GAC manually fixed the issue for me. To do this:
- Open the "Developer Command Prompt for VS (SSDT)" in admin mode.
- Run this command: gacutil -i "assembly name"
For the assembly name, I just needed to browse my local drive for a copy of the DLL i was adding and then use the full file path (C:...Newtonsoft.json.dll) in the "assembly name".
https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-install-an-assembly-into-the-gac
https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs
回答2:
Try installing Json.Net from solution explorer:
- json.net How to Install Json.Net in Visual Studio Projects
Workaround
Instead of using Json.Net you can benefit from System.Web.Extension
assembly which is a part of the .Net Framework, you can refer to the following link for a step by step guide on how to parse JSON using this assembly:
- Importing JSON Files Using SQL Server Integration Services
来源:https://stackoverflow.com/questions/55577736/newtonsoft-json-package-requires-reinstall-every-time-i-open-code