Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 97455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:00:29+00:00 2026-05-11T00:00:29+00:00

I have an SSIS package that executes several tasks. I manually added an event

  • 0

I have an SSIS package that executes several tasks. I manually added an event handler inside Business Intelligence Studio 2005 at the package level for the OnExecStatusChanged event.

My question is, how can I add a handler for this event inside C#? I have loaded the package as pointed here and I also created a custom class inherited from Microsoft.SqlServer.Dts.Runtime.DefaultEvents which is my ‘Listener’:

    Microsoft.SqlServer.Dts.Runtime.SqlPackageEventListener sqlListener = new SqlPackageEventListener();     Microsoft.SqlServer.Dts.Runtime.Application sqlPackageLoader = new Application();     Microsoft.SqlServer.Dts.Runtime.Package sqlPackage = sqlPackageLoader.LoadPackage(@'path\MigrateData.dtsx', sqlListener);     sqlPackage.Execute(null, null, sqlListener, null, null); 

If I check the sqlPackage.EventHandlers.Count property I get the right number for handlers added inside Business Intelligence Studio.

Is there some way to handle those events inside C#?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:00:30+00:00Added an answer on May 11, 2026 at 12:00 am

    Well I did not find anything so I came up with a work around so I will auto-respond to me:

    Since there is no way to directly catch the events that the SSIS package make then I implemented my own events inside my listener:

    public class SqlPackageEventListener : DefaultEvents {     public SqlPackageChangedHandler OnPackageError;      public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError) {         OnPackageError(this, new PackageErrorEventArgs(source, subComponent, description));         return base.OnError(source, errorCode, subComponent, description, helpFile, helpContext, idofInterfaceWithError);     }      public delegate void SqlPackageChangedHandler(         object sqlPackage,         EventArgs packageInfo         ); }  public class PackageErrorEventArgs : EventArgs  {     private DtsObject source;     public DtsObject Source {         get { return source; }         set { source = value; }     }      private string subcomponent;     public string Subcomponent {         get { return subcomponent; }         set { subcomponent = value; }     }      private string description;     public string Description {         get { return description; }         set { description = value; }     }      public PackageErrorEventArgs(DtsObject source, string subcomponent, string description) {         this.description = description;         this.source = source;         this.subcomponent = subcomponent;     } }  public class Test  {     SqlPackageEventListener sqlListener = new SqlPackageEventListener();     sqlListener.OnPackageError += new SqlPackageEventListener.SqlPackageChangedHandler(sqlListener_OnPackageError);     Microsoft.SqlServer.Dts.Runtime.Application sqlPackageLoader = new Microsoft.SqlServer.Dts.Runtime.Application();     Microsoft.SqlServer.Dts.Runtime.Package sqlPackage = Microsoft.SqlServer.Dts.Runtime.sqlPackageLoader.LoadPackage(@'path_to\file.dtsx', sqlListener);     sqlPackage.Execute(null, null, sqlListener, null, null)      public void sqlListener_OnPackageError(object sender, EventArgs args) {         //code to handle the event     } }  

    So the ‘trick’ is to add a delegate to your ‘Listener’ object that you pass to the LoadPackage method of the Package object, that way, we can access the ‘OnError’ override inside the listener and raise the event. As you can see I implemented my own EventArguments class so we can pass important data to our handler code and see what package is running or any other information that you can get from overriding the methods when you inherit from DefaultEvents.

    Of course I only implemented OnError here, you can implement any other handler you like that is supported by SQL Server and that can be overrided since that is the scope where we raise the event.

    That way I can create my SqlPackageEventListener object and handle it’s ‘OnPackageError’ event with the sqlListener_OnPackageError method and do whatever I need in case of any error that the execution of the SSIS package caused.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 109k
  • Answers 109k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can't call the super method in other objects -… May 11, 2026 at 9:22 pm
  • Editorial Team
    Editorial Team added an answer I would go for step 2 (almost, as it does… May 11, 2026 at 9:22 pm
  • Editorial Team
    Editorial Team added an answer If your plugin are RCP (Rich Client Platform) plugins, with… May 11, 2026 at 9:22 pm

Related Questions

I have an SSIS Package stored in the MSDB database which works fine when
In an SSIS package, I have a For Loop Container task with the EvalExpression
I have an issue executing a package via the API at Microsoft.SqlServer.Dts.Runtime. I have
I am running an Execute SQL Task statement in my SSIS package. The Execute

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.