脚本任务失败而没有进入内部尝试&抓住块

时间:2018-03-19 14:57:30

标签: c# error-handling ssis try-catch

以下是我在SSIS中编写脚本任务的简要说明。

  1. 读/写变量spawn,它存在于LOGERROR面板中,Variables类型。
  2. 在脚本内部,C#代码:

    string
  3. 我手动控制变量写入的原因是,为了try { ... //what here does is to iterate a folder and move all of them to another folder, codes here are working correctly Dts.TaskResult = (int)ScriptResults.Success; } catch(Exception e) { Variables lockedVariables = null; Dts.VariableDispenser.LockOneForWrite("User::LOGERROR", ref lockedVariables); lockedVariables["User::LOGERROR"].Value = e.ToString(); lockedVariables.Unlock(); Dts.TaskResult = (int)ScriptResults.Failure; } 的相同目的,LOGERROR添加了相同的变量Event Handler

  4. 我将Point 4定向到另一个Failure,它试图将Execute SQL task(应包含异常详细信息)插入到基础表中。 我的问题: 有时SSISPackage在上述任务中失败(并非总是如此,但几乎每天都在同一时间,可能与其他工作有冲突?)没有任何明显的原因(至少目前为止)。这就是为什么我想跟踪究竟是什么问题,但是如果我查询目标日志记录表。细节没有显示任何内容,只是空的。

  5. 而且,我在LOGERROR中有一个常规日志记录任务,当任务运行时出现错误,记录了所有消息。该消息只显示Event Handler

    尝试记录Exception has been thrown by the target of an invocation.时是否遗漏了一些内容?因为在我看来脚本没有进入LOGERROR,只是直接失败,否则应该存储Try & Catch详细信息。 (如果我错了,请纠正我)。或者,我如何跟踪错误详细信息?

1 个答案:

答案 0 :(得分:0)

经过一些调查,我认为问题是由SQL Server Agent failed to access the shared folder during certain time frame引起的。

我的问题的可能解决方案:

https://social.technet.microsoft.com/Forums/azure/en-US/988207fe-5a25-4da7-a8df-a38fada703da/ssis-script-task-exception-has-been-thrown-by-target-of-invocation?forum=sqlintegrationservices