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 6216845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:19:20+00:00 2026-05-24T07:19:20+00:00

I have a delegate which is attached to an event in the Excel interop

  • 0

I have a delegate which is attached to an event in the Excel interop component. The goal is to update a winforms control with updated info from Excel. Since I’m changing Control properties I need to use Invoke:

public delegate void DataGridViewUpdate(object[,] data);

...

excel.InteractiveEdit( delegate(object[,] data) { 
    Invoke(new Common.DataGridViewUpdate(back_from_excel), new object[] { data }); 
});

...

private void back_from_excel(object[,] data) {
    // datagridview updating code
    // an exception is thrown here !
}

(This code is in the Form class that I’m updating so it’s Invoking on this)

Basically my problem is that when an exception occurs in the back_from_excel(object[,] data) method, the debugger doesn’t catch it. I know the delegate is running in the correct UI thread because I have no problems manipulating form controls.

Specifically what happens is that when back_from_excel hits an unhandled exception, it stops executing at that point. The rest of the application continues running and is responsive. The debugger doesn’t pause. The output pane shows:

A first chance exception of type 'System.NullReferenceException' occurred in My Application.exe
A first chance exception of type 'System.NullReferenceException' occurred in System.Windows.Forms.dll

It doesn’t give me any hints about which line caused the problem, just that it’s somewhere in the .exe.

My question is: am I doing the Invoke thing right? It seems kind of strange to have delegate – Invoke – delegate chained together like that, but I do need to pass a delegate that Invokes a delegate. Is my problem in Visual Studio rather than in C#? If so how do I get the debugger re-attached to that UI thread?

  • 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-05-24T07:19:22+00:00Added an answer on May 24, 2026 at 7:19 am

    A “first chance exception” indicates that an exception was thrown, but that it was caught at some point. Since you’re passing a delegate to the InteractiveEdit method, that method can easily swallow any exceptions produced by the delegate.

    By default, Visual Studio will only catch exceptions that don’t get caught. If you want to catch all exceptions, regardless of whether they are caught, you need to configure Visual Studio to break on all exceptions. See this link for details on how to do this.

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

Sidebar

Related Questions

I have a pinch gesture recognizer attached to an imageview from which I use
In c# we have the event keyword which is an special kind of delegate
I am having a scenario, in which i have multiple delegates attached to the
I have my main application delegate which contains a method that returns an object.
Can we have same delegate for two events ? which have same number of
I am very very new to delegates! I have an AsyncCallback delegate which runs
I am trying to create a TreeView from the Silverlight TreeView control. I have
I have a jQuery delegate which calculates the sum of textboxes when the user
I have an app which has UITabBar with 5 views, each attached to a
I have two string properties setup in my cocoa application's app delegate which are

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.