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

  • SEARCH
  • Home
  • 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 7828281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:17:26+00:00 2026-06-02T10:17:26+00:00

I am using a singleton pattern for a global event manager class that is

  • 0

I am using a singleton pattern for a global event manager class that is not handling exceptions in an acceptable manner.

If an exception is thrown in the code called by one of the events being executed, I always get a Exception has been thrown by the target of an invocation. error. This error contains no information related to the original exception, making it extremely difficult to debug any errors.

Is there some way to pass the original exception information back to the event manager?

public class ApplicationSettings
{
    private static EventManager _manager = new EventManager();

    public static EventManager EventManager
    {
        get { return _manager; }
    }
}

The event manager class:

public class EventManager
{
    public event EventHandler<ReportExecutionArgs> ExecuteReportCurrentPage;
    public event EventHandler<ReportExecutionArgs> ExecuteReportNewPage;

    public virtual void OnExecuteReportCurrentPage(object sender, ReportExecutionArgs e)
    {
        try
        {
            if (this.ExecuteReportCurrentPage != null)
                this.ExecuteReportCurrentPage(sender, e);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }

    public virtual void OnExecuteReportNewPage(object sender, ReportExecutionArgs e)
    {
        try
        {
            if (this.ExecuteReportNewPage != null)
                this.ExecuteReportNewPage(sender, e);
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
}

Some other class will handle these events

ApplicationSettings.EventManager.ExecuteReportNewPage += new EventHandler<ReportExecutionArgs>(reportOpenedNewPage);

private void reportOpenedNewPage(object sender, ReportExecutionArgs e)
    {
        //something in this code throws an error
        LitePage page = new LitePage();
        _tabs.AddPage(page);
        Report report = setReport(page, e);
    }

EDIT

Just to clarify, the try/catch blocks in the OnExecuteReport methods are not catching the exception.

  • 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. Editorial Team
    Editorial Team
    2026-06-02T10:17:28+00:00Added an answer on June 2, 2026 at 10:17 am

    A TargetInvocationException such as the one you describe will almost always have the originating exception in it’s InnerException.

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

Sidebar

Related Questions

I'm using a singleton pattern for the datacontext in my web application so that
Currently I'm using singleton pattern for certain global objects in my application (Qt application
I know that Singleton pattern is bad because it uses global state. But in
I'm implimenting my own ApplicationContext class that uses the singleton pattern. I want to
I have a class that implements singleton pattern as you can see below: public
I have a static DataLibrary class that implements a singleton pattern. public static FacilityRepository
I am using the singleton pattern in all my PHP class files. Would it
I am trying to write a db util class using the singleton pattern. My
Due to the flooding examples of implementing logger using Singleton pattern, I have just
In android, are using static variables a recommended practice? E.g, implementing a Singleton pattern

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.