您可以使用反射从文件系统运行时加载的dll,而无需在GAC中安装。如果无法在GAC中安装权限,这很有帮助。
//Add a Static Constructor which is guaranteed to be called exactly once
// “before the first instance is created or any static members are referenced.”,
// so therefore before the dependent assemblies are loaded.
static ScriptMain()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}
//Provide path to dll stored in folder on file system
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string path = @"D:\DLL\";
return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Newtonsoft.dll"));
}
当然,您还需要在脚本任务中添加对dll的引用。
那可能是你的问题了。我目前正在开发SSIS控制流任务,并发现与我的任务UI项目相同的问题。最后我必须注册它,因为我没有找到其他解决方案。是否有理由不能将其添加到GAC? – zeencat 2012-07-23 11:10:27