.net DTS 脚本任务运行时错误:调用目标已抛出异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24642603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DTS Script Task Runtime Error: Exception has been thrown by the target of an invocation
提问by bsivel
I have a ssis project developed in vs 2012 Ultimate. I use project deployment model and the project is set to run in 32 bit mode. The package executes without error in my development environment but when I deploy it to the ssis catalog and attempt to run it there, I get the following error:
我有一个在 vs 2012 Ultimate 中开发的 ssis 项目。我使用项目部署模型,项目设置为在 32 位模式下运行。该包在我的开发环境中执行没有错误,但是当我将它部署到 ssis 目录并尝试在那里运行它时,我收到以下错误:


I deploy the project to a Windows Server 2012 R2 and the database is also 2012 with an SSIS catalog.
我将项目部署到 Windows Server 2012 R2,数据库也是 2012,带有 SSIS 目录。
I have opened the project on the server and attempted to debug the script task on the server with a break point but the error occurs prior to getting to the break point.
我已经在服务器上打开了该项目,并尝试使用断点调试服务器上的脚本任务,但在到达断点之前发生错误。
If I disable all of my script tasks, the package executes without error on the server.
如果我禁用所有脚本任务,程序包将在服务器上执行而不会出错。
I have also updated the servers local security options by disabling System Cryptography: Use FIPS Compliant Algorithmsas a possible solution posted on Microsoft Support.
我还通过禁用System Cryptography: Use FIPS Compliant Algorithms作为Microsoft Support上发布的可能解决方案更新了服务器本地安全选项。
I have also attempted to run as a file system package on the server and I get the same error.
我还尝试在服务器上作为文件系统包运行,但出现相同的错误。
I have also triple checked that my variables are correct and even set them as read write variables.
我还三重检查了我的变量是否正确,甚至将它们设置为读写变量。
The first script task code is below (but all scrip tasks fail / three in this package). The script task references a dll called UHS.IntegrationServices.CommonUtils that has been GACed and the dll was built in VS 2005 with framwork 2.0.50727.
第一个脚本任务代码如下(但所有脚本任务都失败了/这个包中的三个)。该脚本任务引用了一个名为 UHS.IntegrationServices.CommonUtils 的 dll,该 dll 已经过 GAC 并且该 dll 是在 VS 2005 中使用框架 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
The problem appears to be in the reference to the dll. When I comment out the NotifyInterface and NotifyListener lines the script executes without error but the dll is in the GAC and I can view it in C:\Windows\assembly.
问题似乎出在对 dll 的引用中。当我注释掉 NotifyInterface 和 NotifyListener 行时,脚本执行没有错误,但 dll 在 GAC 中,我可以在 C:\Windows\assembly 中查看它。
Why would this work on my local but not the Server? Is the 2.0 framework needed on the server? If the reference to the dll is broken, shouldn't I get a more descriptive error?
为什么这会在我的本地而不是服务器上工作?服务器上需要2.0框架吗?如果对 dll 的引用被破坏,我不应该得到一个更具描述性的错误吗?
Any assistance in finding trouble shooting ideas would be greatly appreciated.
任何帮助找到解决问题的想法都将不胜感激。
回答by Isaac
You need to set a breakpoint at the beginning of the FIRST script task, just as you would do in any VB debugging situation. Then F8 through each line of code until an error is thrown.
您需要在 FIRST 脚本任务的开始处设置断点,就像在任何 VB 调试情况下所做的一样。然后 F8 遍历每一行代码,直到抛出错误。
回答by Ling
My issue was solved. "The problem that we had was that our .net reference for Analysis Management Objects was 11.0 (2012) and it needed to be 12.0 (2014). "
我的问题解决了。“我们遇到的问题是我们对分析管理对象的 .net 引用是 11.0 (2012),它需要是 12.0 (2014)。”
链接:https: //mitchellpearson.com/2015/04/13/upgrading-script-tasks-in-ssis-target-of-invocation-on-script-task/
回答by Edward
I found the issue was a Reference that I had just added that hadn't been registered in the GAC. I ran the 'AddToGAC.bat' routine, and the task then ran successfully.
我发现问题是我刚刚添加的未在 GAC 中注册的参考。我运行了“AddToGAC.bat”例程,然后任务成功运行。

