SSIS脚本任务找不到对程序集的引用 [英] SSIS Script Task cant find reference to assembly
问题描述
我有一个SSIS包,该包使用脚本任务来填充来自包括excel在内的各种不同文件类型的数据的数据表。
我正在使用NPOI进行读取在Excel数据中输入NPOI.dll文件,并将其与SSIS包放在同一文件夹中,并将其添加为脚本任务中的引用。在NPOI方面,我是个菜鸟,所以我现在只是在修补,但即使是我,我仍然还是遇到了第一个障碍!
我的脚本包含下面的代码(我从
如果我注释掉除第一行以外的所有内容声明名为 wb
的 HSSFWorkBook
运行正常。
我是否添加了错误的引用,或者添加对SSIS脚本任务的引用非常困难?
一如既往,我们将不胜感激。
要在脚本任务中引用和执行自定义程序集,必须将其添加到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屋!