DTS脚本任务运行时错误:调用目标已抛出异常

时间:2014-07-08 22:38:20

标签: .net vb.net visual-studio-2012 ssis

我在vs 2012 Ultimate中开发了一个ssis项目。我使用项目部署模型,项目设置为以32位模式运行。包在我的开发环境中执行时没有错误,但是当我将它部署到ssis目录并尝试在那里运行时,我收到以下错误:

error dialog

我将项目部署到Windows Server 2012 R2,数据库也是2012年的SSIS目录。

我在服务器上打开了项目,并尝试使用断点调试服务器上的脚本任务,但错误发生在到达断点之前。

如果我禁用了所有脚本任务,则程序包在服务器上执行时没有错误。

我还通过禁用系统加密:使用FIPS兼容算法作为Microsoft Support上发布的可能解决方案来更新服务器本地安全选项。

我还试图在服务器上作为文件系统包运行,但我得到了同样的错误。

我还检查过我的变量是否正确,甚至将它们设置为读写变量。

第一个脚本任务代码如下(但所有脚本任务失败/此包中有三个)。脚本任务引用了一个名为UHS.IntegrationServices.CommonUtils的dll,它已被GACed和dll在VS 2005中使用framwork 2.0.50727构建。

Public Sub Main()

    Dim packageID As String = Dts.Variables("System::PackageID").Value.ToString()
    Dim strInterfaceName As String = Dts.Variables("System::PackageName").Value.ToString()
    Dim strConfigConnectionString1 As String = Dts.Variables("User::UHS_SSIS_CNXN_STR_CONFIG").Value.ToString()
    Dim myConnection As OleDb.OleDbConnection = New OleDb.OleDbConnection
    Dim mySqlCommand As OleDb.OleDbCommand = New OleDb.OleDbCommand
    Dim myReader As OleDb.OleDbDataReader = Nothing
    Dim rowsProcessed As Integer = 0

    Try
        myConnection.ConnectionString = strConfigConnectionString1
        myConnection.Open()

        Dim getEmailQuery As String = "SELECT Email FROM EmailMaster" & _
                                      " where InterfaceName='" & strInterfaceName & "'" & _
                                      " and Active = 'Y' "

        Dim NotifyInterface As SMTPNotifyAlerts
        NotifyListenerManager.GetNotifierByType(packageID, NotifyInterface, CommonNotifierAlerts.AlertInfo.AlertTypes.alertEmail)


        mySqlCommand = New OleDb.OleDbCommand(getEmailQuery, myConnection)
        mySqlCommand.CommandTimeout = 0
        myReader = mySqlCommand.ExecuteReader

        If (myReader.HasRows()) Then
            While (myReader.Read())
                NotifyInterface.alertDest.Add(myReader("Email").ToString().Trim())
                rowsProcessed = rowsProcessed + 1
            End While
        End If

        NotifyListenerManager.BroadcastMessage(CommonNotifierAlerts.BasicAlerts, 0, Nothing, "Startup logfile")
        Dts.TaskResult = ScriptResults.Success
    Catch ex As Exception
        Dts.Events.FireError(0, "Init Email Master", ex.Message, "", 0)
        Dts.TaskResult = ScriptResults.Failure
    End Try

End Sub

问题似乎在对dll的引用中。当我注释掉NotifyInterface和NotifyListener行时,脚本执行时没有错误,但是dll在GAC中,我可以在C:\ Windows \ assembly中查看它。

为什么这会在我的本地而不是服务器上运行?服务器上是否需要2.0框架?如果对dll的引用被破坏,我不应该得到更具描述性的错误吗?

非常感谢任何寻找解决问题的帮助。

3 个答案:

答案 0 :(得分:4)

您需要在FIRST脚本任务的开头设置断点,就像在任何VB调试情况下一样。然后F8通过每行代码,直到抛出错误。

答案 1 :(得分:1)

我的问题已经解决了。 "我们遇到的问题是我们的Analysis Management Objects的.net参考是11.0(2012),它需要是12.0(2014)。 "

链接:https://mitchellpearson.com/2015/04/13/upgrading-script-tasks-in-ssis-target-of-invocation-on-script-task/

答案 2 :(得分:0)

我发现问题是我刚刚添加的参考文献,尚未在GAC中注册。我运行了“ AddToGAC.bat”例程,然后任务成功运行。