“运行时错误异常已被调用的目标抛出"从脚本任务 [英] "Runtime error Exception has been thrown by the target of an invocation" from Script task

查看:21
本文介绍了“运行时错误异常已被调用的目标抛出"从脚本任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有脚本任务的 SSIS 包,当我尝试在本地系统中运行它时出现以下错误.它适用于我的同事以及生产环境.但是,我无法在本地运行它进行测试.我在 main 方法中保留了一个调试点,但从未达到过,我在进入 main 方法之前收到了错误.

I have a SSIS package with a script task, I get the following error when i try to run it in my local system. It works fine for my collegues as well as in production. However, I am not able to run it locally, to test. I keep a debug point in the main method, but it is never reached, I get the error before it goes to main method.

我使用的是 VS 2010,.Net 框架 4.5.

I am using VS 2010, .Net framework 4.5.

脚本任务确实编译.我开始收到以下消息 SSIS 包..Test.dtsx".错误:0x1 在测试:调用的目标已抛出异常.任务失败:测试 SSIS 包..Test.dtsx"完成:成功.程序[2552] DtsDebugHost.exe: DTS"已退出,代码为 0 (0x0).

The script task does compile. I get the following messages SSIS package "..Test.dtsx" starting. Error: 0x1 at Test: Exception has been thrown by the target of an invocation. Task failed: Test SSIS package "..Test.dtsx" finished: Success. The program '[2552] DtsDebugHost.exe: DTS' has exited with code 0 (0x0).

代码如下:

public void Main()
{
try
{
 LogMessages("Update Bug package execution started at :: " + DateTime.Now.ToLongTimeString());
 LogMessages("Loading package configuration values to local variables.");

strDBConn = Dts.Variables["User::DBConnection"] != null ? Dts.Variables["User::DBConnection"].Value.ToString() : string.Empty;
strTPCUrl = Dts.Variables["User::TPCUrl"] != null ? Dts.Variables["User::TPCUrl"].Value.ToString() : string.Empty;

TfsTeamProjectCollection objTPC = new TfsTeamProjectCollection(new Uri(strTPCUrl));
WorkItemStore objWIS = new WorkItemStore(objTPC);
WorkItemCollection objWIC = objWIS.Query("SELECT...");

foreach (WorkItem wi in objWIC)
{
}

}
catch(Exception ex)
{
}

当我评论 TfsTeamProjectCollection objTPC = new TfsTeamProjectCollection(new Uri(strTPCUrl)) 中的代码时;脚本成功执行.但是,如果我保留 TfsTeamProjectCollection objTPC = new TfsTeamProjectCollection(new Uri(strTPCUrl));并评论其余部分,我得到了例外.我确实可以访问该 URL.

When I commented the code from TfsTeamProjectCollection objTPC = new TfsTeamProjectCollection(new Uri(strTPCUrl)); The script executes successfully. However, if i keep TfsTeamProjectCollection objTPC = new TfsTeamProjectCollection(new Uri(strTPCUrl)); and comment the rest, i get the exception. I do have access to the URL.

我在我的脚本任务中使用 Microsoft.TeamFoundation.Client.dll 和 Microsoft.TeamFoundation.WorkItemTracking.Client.dll.但是包里的dll版本是10.0,我的GAC里面的dll版本是12.0.这会导致问题吗?

I am using Microsoft.TeamFoundation.Client.dll and Microsoft.TeamFoundation.WorkItemTracking.Client.dll, in my script task. However the dll version in the package is 10.0, and the version of the dll in my GAC is 12.0. Would that cause a problem?

推荐答案

我通过更改 SSIS 项目TargetServerVersion 修复了这个错误.

I fixed this error by changing the TargetServerVersion of the SSIS Project.

集成服务项目属性页

这篇关于“运行时错误异常已被调用的目标抛出"从脚本任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆