SSIS 包不是来自服务器的 运行

SSIS Package not running from server

我有一个执行以下操作的 SSIS 程序包;

  1. 检测文件是否存在(excel 存在)
  2. 删除文件
  3. 将文件从目录复制到所需目录

此包在 运行 本地测试功能正常时没有问题。

当 运行 在服务器上或作为作业时,我得到

的错误

Exception has been thrown by the target of an invocation.

我认为错误是基于复制代码行,因为注释掉它仍然允许包 运行。

我的 Visual Studio 版本是 2013(无法升级),SQL-服务器机器是 运行2016 的最新版本。

用于运行作业的帐户被视为网络管理员 - 错误仍然存​​在。

Imports System.IO (etc)

Public Sub Main()
        Dim sourcePath As String = "\server\File\Template.xlsx"
        Dim destPath As String = "\server\File\NewFile.xlsx"


        If File.Exists(destPath) = True Then
            File.Delete(destPath)       'deletes current file
        End If
        File.Copy(sourcePath, destPath)
        Dts.TaskResult = ScriptResults.Success
End Sub

我预计这样做不会有任何问题,因为其他包(不同的功能等)可以正常工作。

Exception has been thrown by the target of an invocation.

这是一条通用脚本任务消息。非常标准的建议:考虑通过 FireError:

捕获真实的异常文本以更好地分析问题
Imports System.IO (etc)

Public Sub Main()
Try

    Dim sourcePath As String = "\server\File\Template.xlsx"
    Dim destPath As String = "\server\File\NewFile.xlsx"

    If File.Exists(destPath) = True Then
    File.Delete(destPath)       'deletes current file
    End If
    File.Copy(sourcePath, destPath)


Catch ex As Exception
   Dts.Events.FireError(0, "Script Task Example", ex.Message, String.Empty, 0);  
End Try

    Dts.TaskResult = ScriptResults.Success

End Sub

此类代码失败的原因有很多,其中之一与 in-place 软件包升级有关,该升级未将脚本任务正确升级到 VSTA 2015。

由于 Visual Studio 2013 和 SQL 服务器 2016 中编写的 SSIS 包之间的版本控制差异,存在错误。

可以在错误报告的消息部分找到升级错误。