Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将newtonsoft安装到全局程序集缓存以用于SSIS脚本任务_C#_Ssis_Json.net_Gac - Fatal编程技术网

C# 将newtonsoft安装到全局程序集缓存以用于SSIS脚本任务

C# 将newtonsoft安装到全局程序集缓存以用于SSIS脚本任务,c#,ssis,json.net,gac,C#,Ssis,Json.net,Gac,我正在使用newtonsoft dll解析SSIS脚本任务中的json数据。这在我的本地计算机上正常工作,但部署到SQL Server并从SQL Server运行时,作业会抛出错误: “调用的目标已引发异常” 我正在尝试将newtonsoft dll安装到全局程序集缓存。为了做到这一点,我必须将Newtonsoft安装到服务器上,例如它保存到C目录。然后使用gacutil将其安装到全局程序集缓存 C:\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Js

我正在使用newtonsoft dll解析SSIS脚本任务中的json数据。这在我的本地计算机上正常工作,但部署到SQL Server并从SQL Server运行时,作业会抛出错误:

“调用的目标已引发异常”

我正在尝试将newtonsoft dll安装到全局程序集缓存。为了做到这一点,我必须将Newtonsoft安装到服务器上,例如它保存到C目录。然后使用gacutil将其安装到全局程序集缓存

 C:\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
    
 gacutil /i Newtonsoft.Json.dll
在脚本任务C#代码中引用dll,如下所示

static ScriptMain()
{
    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);           
}

static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{          
    string path = @"C:\Newtonsoft.Json.12.0.3\lib\net45\";
    return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Newtonsoft.Json.dll"));
}

如果使用,则无需将其安装在GAC中,只需确保DLL与代码中引用的服务器路径相同

C:\Newtonsoft.Json.12.0.3\lib\net45\


如果使用,则无需将其安装在GAC中,只需确保DLL与代码中引用的服务器路径相同

C:\Newtonsoft.Json.12.0.3\lib\net45\