0

I am new in SSIS. I am trying to convert the string into JSON format as shown in the figure. I install the Newtonsoft Json. But it's showing yellow triangle mark.

I have installed all the version of Newtonsoft. But still it's showing the error while #

region Namespaces
using Newtonsoft.Json.Linq;
using System;
using System.Windows.Forms;#
endregion

namespace ST_9a0af2e4537b4d26adaef11149343faa {

 public partial class ScriptMain: Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase {



  public void Main() {


   var myJsonString = "{report: {Id: \"aaakkj98898983\"}}";
   MessageBox.Show(myJsonString);

   try {
    // when i add this line to my package then the package is not 
    excuting.if i remove this line then package is excuting.
    JObject.Parse("{report: {\"Id\": \"aaakkj98898983\"}}");
   } catch (Exception e) {
    MessageBox.Show(e.ToString());
   }




   Dts.TaskResult = (int) ScriptResults.Success;
  }

 }
}

the script task. My IDE version is Visual Studio 2015 Professional.

After installing the Newtonsoft does not show. When I close the script task popup and again open the script task editor, it showing the yellow exclamation mark, and when I select the Newtonsoft package and check the properties it path & version is showing 0.0.0.0. Then I downloaded the Newtonsoft package and reference the newtonsoft.json.dll file add reference. Then it showing the path and version.

But when I run the package it showing the error.

I have tried by following the article also, but didn't get success.

Convert JSON String to JSON Object c# https://www.c-sharpcorner.com/article/json-serialization-and-deserialization-in-c-sharp/ https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Linq_JObject_Parse.htm https://www.nuget.org/packages/System.Json/ How to parse JSON without JSON.NET library? Json does not exist in the namespace System Parse JSON string using C# script in SSIS https://learn.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio https://www.dotnetjalps.com/2014/04/converting-csharp-object-json-string.html Cannot find JavaScriptSerializer in .Net 4.0

https://riptutorial.com/json-net/topic/1861/getting-started-with-json-net http://www.rockprogrammer.com/2017/08/how-to-install-json-.net-in-visual-studio-2015.htmls

Can one help me to solve this problem?

Thanks
Shiv roy

Armali
  • 18,255
  • 14
  • 57
  • 171
shiv roy
  • 11
  • 1
  • 3
  • Is there multiple projects in your solution? – Akbar Badhusha Jan 03 '19 at 08:07
  • What error are you getting ? – RazorShorts Jan 03 '19 at 08:10
  • In the reference peroperties, is CopyLocal set to True of False? CopyLocal means that the referenced dll is copied to the output build location of the assembly. If its not present there, this can result in the code compiling successfully (since Visual Studio references the dll) but fails during runtime (since the dll is not present at the moment it needs to be loaded). – JonyVol Jan 03 '19 at 08:16
  • Are you using the **NuGet package manager**? If not: *erase Newtonsoft entirely from your project (both the files + any references you may have)*, then go to `your solution` -> `Manage NuGet Packages For Solution`, find Newtonsoft.Json and add a recent version of it to the projects that need it. – Peter B Jan 03 '19 at 09:20

2 Answers2

0

It's possible there are few references to Newtonsoft.Json(for instance one of the your assemblies may reference to specified version as well).

To check that you can use AsmSpy tool to check assembly references with the following command:

AsmSpy "Here is the path to your bin directory"

Please read more detailed about AsmSpy here: https://github.com/mikehadlow/AsmSpy

It may help to analyze what's wrong with your references

Eugene Rotar
  • 83
  • 1
  • 2
  • 9
0

Thanks to EveryOne .

Finally i am able to resolve the issue the issue by flowing the Joost van Rossum article . Thanks to Joost van Rossum

Add the assembly to GAC Before we can use our assembly, we have to add it to the global assembly cache (GAC). Open the Visual Studio 2008 Command Prompt again (for Vista/Windows7/etc. open it as Administrator). And execute the following command. gacutil /i d:\myMethodsForSSIS\myMethodsForSSIS\bin\Release\myMethodsForSSIS.dll

for more information please read this article http://microsoft-ssis.blogspot.com/2011/05/referencing-custom-assembly-inside.html https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d70cac36-6aa5-42cb-89a8-1a24cb5a0cad/cant-find-external-dll-reference-in-ssis-2012-script-task?forum=sqlintegrationservices

shiv roy
  • 11
  • 1
  • 3