简体   繁体   中英

Creating a reference to a custom assembly from an SSIS Script Task - vb

I am looking for a way to create an "Imports Newtonsoft.Json.Linq" in my SSIS script task, but this is apparently not as simple as a "manage NuGet Packages" in SSIS. So is there another way around this.

I have found a link to what looks to me like a possible solution, but as I am no skilled programmer, I am having trouble translating from C# into vb. I am hoping that there is someone out there that can help me, or perhaps guide me in another direction.

I am using Visual Studio 2010 Shell, .Net Framework 4.6.0, and the company code language is vb.

Here is a copy of the C# code from the link above. :

[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
     static ScriptMain()
     {
         AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
     }
     static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
     {
         if (args.Name.Contains("ssisHelper"))
         {
             string path = @"c:\temp\";
             return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "ssisHelper.dll"));
         }
         return null;
     }
    . . .

Not Possible.

If you add any third party library(.dll) file, the SSIS will run inside the visual studio(local). So, in local it will work fine (while running in Visual Studio). But once you run it through the SQL Server Job/ETL, it will not.

The only way is you need to add your third party library/libraries in "GACUTIL" of the server where your SSIS is running(through SQL-JOB/ETL...).

As you have mentioned, you are using "Newtonsoft.Json", so, copy the Newtonsoft.Json.dll to the server (gacutil) where SSIS package is running.

Try this and let me know if you face any issues

You have to add Newtonsoft.Json dll file to the following directories

(1) .Net Framework dll directory

 C:\Windows\Microsoft.NET\Framework\v[.net installed version]\ 

example

C:\Windows\Microsoft.NET\Framework\v4.0.30319\

(2) SQL server data tools dll runtime directory

C:\Program Files (x86)\Microsoft SQL Server\[SQL Server version]\DTS\Binn

example

C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn

After that, in the Script Task, go to project explorer, you and then add this dll as a reference, it will appear in the references listed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM