[英]How to solve “Exception has been thrown by the target of an invocation.” this error
[英]How to solve "Runtime error Exception has been thrown by the target of an invocation" Am I missing a DLL file?
调用的目标已抛出异常
是脚本代码引发异常时显示的一般错误消息。 要阅读主要错误消息,您可以在代码中添加 try catch 子句并使用Dts.FireError()
方法抛出真正的异常。
public void Main()
{
try
{
string strMessage = Dts.Variables["User::FinalTieOut"].Value.ToString();
Messagebox.Show(strMessage);
Dts.TaskResult = (int)ScriptResults.Success;
}
catch(Exception ex)
{
Dts.Events.FireError(0,"An error occured", ex.Message,String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
基于在脚本任务中使用变量 - 官方文档:
您将现有变量添加到脚本任务编辑器中的 ReadOnlyVariables 和 ReadWriteVariables 列表,以使它们可用于自定义脚本。 请记住,变量名区分大小写。 在脚本中,您可以通过 Dts 对象的 Variables 属性访问这两种类型的变量。 使用 Value 属性读取和写入单个变量。 脚本任务在脚本读取和修改变量值时透明地管理锁定。
只需将USER::FinalTieOut
更改为User::FinalTieOut
解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.