简体   繁体   中英

SSIS Package Fails To Run With Script Task

I've got a Console app that tries to run an SSIS package (in Package Deployment Mode). Both the console app and the SSIS package are located on my C: drive. The code works as long as the called package doesn't contain a Script Task. When the called package contains a Script Task, I get this error:

Package Execution results: The task has failed to load. The contact information for this task is "".
Package Execution results: There were errors during task validation.
Package Execution results: The package cannot execute because it contains tasks that failed to load.

I've tried running the called package from SSDT and it runs successfully. But when run from the code below, it fails. Based on answers from similar posts, I've tried changing the TargetServerVersion property of the called package. But the same errors still occur. Both the console app and the called Script Task use .NET Framework 4.7.2 as the target framework.

Any idea what could be wrong?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.SqlServer.Dts.Runtime;

namespace PackageTester
{
    class Program
    {
        static void Main(string[] args)
        {
            string SSISPackagePath = @"C:\-------\console_app_test_2.dtsx";
            string datafilePath = @"C:\-------\datafiles\my_data_file.csv";

            string results = FireSSIS(SSISPackagePath, datafilePath);

            Console.WriteLine(results);
            Console.ReadLine();
        }

        public static string FireSSIS(string packagePath, string FilePath)  
        {
            string result = string.Empty;
            try
            {
                Application app = new Application();
                Package package = null;

                package = app.LoadPackage(packagePath, null);

                Variables myVars = package.Variables;

                myVars["SourceFilePath"].Value = FilePath;

                DTSExecResult results = package.Execute(null, myVars, null, null, null);

                if (results == DTSExecResult.Success)
                {
                    result = "Success";
                }
                else
                {
                    foreach (DtsError local_DtsError in package.Errors)
                    {
                        result += string.Concat($"Package Execution results: { local_DtsError.Description }\r\n");
                    }
                }                
            }

            catch (DtsException ex)
            {
                Console.WriteLine (ex.Message);
            }

            return result;
        }
        
    }
}

This is a known limitation. Any package with a script task will fail to run outside a "proper" integration services installation. It is a licensing issue to my knowledge. There might be additional limitations as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM