如何让自定义DLL在ssis脚本组件中工作?

时间:2016-06-17 12:21:55

标签: vb.net ssis script-component

我尝试在script compoment内的ssis中使用我自己的.dll。正常程序给我一个错误:"could not load file or assembly 'xxx' or one of its dependencies. The system cannot find the file specified."

我尝试的是我去了项目 - >在资源管理器中打开并将我的.dll放入bin文件夹但发生同样的错误。

我找到this C# Code并将其转换为vb.net:

<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute> _
Public Partial Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    Shared Sub New()
        AppDomain.CurrentDomain.AssemblyResolve += New ResolveEventHandler(AddressOf CurrentDomain_AssemblyResolve)
    End Sub
    Private Shared Function CurrentDomain_AssemblyResolve(sender As Object, args As ResolveEventArgs) As System.Reflection.Assembly
        If args.Name.Contains("ssisHelper") Then
            Dim path As String = "c:\temp\"
            Return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "ssisHelper.dll"))
        End If
        Return Nothing
    End Function
End Class

但我没有Micorosoft.SqlServer.Dts.**Tasks**。任何可以帮助我的人都可以使这个脚本工作,或者可以提供另一个解决方案让我的dll在script compoment内运行?

2 个答案:

答案 0 :(得分:0)

您需要通过运行gacutil -i assembly.dll将程序集添加到GAC(全局程序集缓存)

可在此处找到更多信息

https://msdn.microsoft.com/en-us/library/dkkx7f79(v=vs.100).aspx

答案 1 :(得分:0)

And before adding it to the GAC you need to strong name it, example here: http://microsoft-ssis.blogspot.com/2011/05/referencing-custom-assembly-inside.html