在脚本任务中使用nuget包
我正在尝试制作 Microsoft.Azure.Services.AppAuthentication 及其依赖项与 SSIS 脚本任务一起使用。如何解决程序集引用错误?
static ScriptMain()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.Contains("Microsoft.Azure.Services.AppAuthentication"))
{
return System.Reflection.Assembly.LoadFile(@"C:\Azure\packages\Microsoft.Azure.Services.AppAuthentication.1.6.2\lib\net472\Microsoft.Azure.Services.AppAuthentication.dll");
}
if (args.Name.Contains("Microsoft.IdentityModel.Clients.ActiveDirectory"))
{
return System.Reflection.Assembly.LoadFile(@"C:\Azure\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.5.2.9\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll");
}
}
I am trying to make Microsoft.Azure.Services.AppAuthentication and its dependencies work with SSIS script task. How do I resolve assembly reference errors?
static ScriptMain()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.Contains("Microsoft.Azure.Services.AppAuthentication"))
{
return System.Reflection.Assembly.LoadFile(@"C:\Azure\packages\Microsoft.Azure.Services.AppAuthentication.1.6.2\lib\net472\Microsoft.Azure.Services.AppAuthentication.dll");
}
if (args.Name.Contains("Microsoft.IdentityModel.Clients.ActiveDirectory"))
{
return System.Reflection.Assembly.LoadFile(@"C:\Azure\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.5.2.9\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SSIS 脚本任务/组件不支持 Nuget 包。您需要从 GitHub 存储库 手动下载程序集。
接下来,您应该将这些程序集添加到全局缓存程序集 (GAC):
您可以参考以下文章以获得更多指导:
Nuget packages are not supported in SSIS script task/component. You need to download the assemblies manually from the GitHub repository.
Next, you should add these assemblies to the Global cache assembly (GAC):
You can refer to the following article for more guidance: