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

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

问题描述

我有一个带有脚本任务的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 Framework 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天全站免登陆