SSIS包错误 - 通过C#控制台应用程序执行

时间:2016-02-17 08:00:20

标签: c# ssis dts

我是这个线程的新手,我遇到了需要通过C#控制台应用程序执行SSIS包的情况。

以下是我用来执行包的代码。

Package pkg;
Application app;
DTSExecResult pkgResults;

pkgLocation =@"D:\MIS Reports\TERADATA\Daily_CBASQ1_Loading.dtsx";
app = new Application();
pkg = app.LoadPackage(pkgLocation, null);
pkgResults = pkg.Execute();

但它引发了一个错误:

The package failed to load due to error 0xC0011008 
"Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored." 

CPackage::LoadFromXML fails

时会发生这种情况

请帮忙!

2 个答案:

答案 0 :(得分:0)

这更像是评论,但想发布可能有助于调试的代码

您可以添加EventListener,它可以帮助您捕获实际错误。

'~(?:(?![., +-])\P{Xan})+~u'

现在调用这样的包并更新有问题的实际错误

  class MyEventListener : DefaultEvents
      {
        public override bool OnError(DtsObject source, int errorCode, string subComponent, 
          string description, string helpFile, int helpContext, string idofInterfaceWithError)
        {

          Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description);
          return false;
        }
      }

答案 1 :(得分:0)

请在下面找到我的代码:

    static void Main(string[] args)
    {
        string pkgLocation;
        Package pkg;
        Application app;
        DTSExecResult pkgResults;
        MyEventListener eventListener = new MyEventListener();


        pkgLocation =@"D:\MIS Reports\TERA DATA\Daily_CBASQ1_Loading.dtsx";
        app = new Application();
        pkg = app.LoadPackage(pkgLocation,eventListener);
        pkgResults = pkg.Execute();

        Console.WriteLine(pkgResults.ToString());
        Console.ReadKey();
    }
}

class MyEventListener : DefaultEvents
{
    public override bool OnError(DtsObject source, int errorCode, string subComponent,
           string description, string helpFile, int helpContext, string idofInterfaceWithError)
    {
        // Output Error Message
        Console.WriteLine("Error in {0}/{1} : {2}", source, subComponent, description);
        return false;
    }
}

错误:

由于错误0xC0010014&#34,程序包无法加载;发生了一个或多个错误。在此之前应该有更具体的错误来解释错误的细节。此消息用作遇到错误的函数的返回值。"。当CPackage :: LoadFromXML失败时会发生这种情况。