SSIS 脚本任务找不到对程序集的引用 [英] SSIS Script Task cant find reference to assembly

查看:20
本文介绍了SSIS 脚本任务找不到对程序集的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SSIS 包,它使用脚本任务将来自各种不同文件类型(包括 excel)的数据填充到数据表中.

我正在使用 NPOI 从 Excel 中读取数据,并将 NPOI.dll 文件放在与 SSIS 包相同的文件夹中,并将其添加为脚本任务中的参考.我是 NPOI 的菜鸟,所以我现在只是在修修补补,但即使如此,我还是在第一个障碍上摔倒了!

我的脚本包含以下代码(我从

如果我注释掉除了我声明一个名为 wbHSSFWorkBook 的第一行之外的所有内容,它运行良好.

我是否错误地添加了引用,或者添加对 SSIS 脚本任务的引用非常困难?

一如既往,非常感谢任何帮助.

解决方案

要在 Script Task 中引用和执行自定义程序集,您必须将它们添加到 GAC.这是一篇关于工作流程的文章.
替代方法 - 在脚本任务代码中提供您自己的 AssemblyResolver.

I have an SSIS package that uses a script task to populate a datatable with data from a variety of different file types including excel.

I am using NPOI to read in the data from Excel and have put the NPOI.dll file in the same folder as the SSIS package and added it as a reference in the script task. I'm a Noob when it comes to NPOI so I'm only tinkering at the moment, but even still I have fallen at the first hurdle!

My script contains the code below (which i copied from this SA answer):

using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;

HSSFWorkbook wb;
using (FileStream file = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
{
    wb = new HSSFWorkbook(file);
}

but fails with the following error message: Could not load file or assembly 'NPOI, Version=2.1.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1' or one of its dependencies. The system cannot find the file specified

But when I go into the script task, the reference is there and there are no errors.

If I comment out everything except the first line where I declare a HSSFWorkBook called wb it runs fine.

Have I added the references incorrectly or is adding references to a SSIS script task notoriously difficult?

As always any help is greatly appreciated.

解决方案

For custom assemblies to be referenced and executed in Script Task, you have to add them to GAC. Here is an article with workflow.
Alternative approach - provide your own AssemblyResolver in Script task code.

这篇关于SSIS 脚本任务找不到对程序集的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆