Solved

Why do I get "A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll" exception

Posted on 2008-06-25
6
1,689 Views
Last Modified: 2008-06-25
Hi guy,
I'm a bit puzzled as to why I'm getting a "A first chance exception ..." when trying to remove an event handler using "RemoveHandler". I this particular case I have five (5) RemoveHandler statments looking identical, but with different parameters, and only the last statement fails.

The app appears to be working fine so I'm just a bit confused.

Any thoughts?

/Michael
0
Comment
Question by:gem56
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21866732
There are too many possibilities to be sure of anything, without more detail.
0
 

Author Comment

by:gem56
ID: 21866990
As part of creating a Form instance I added several event handlers that includes the following statement:
   "AddHandler Me.ParentSection.Panel.Click, AddressOf Me.Sections.ParentForm.DeselectAllSectionsClick"

Then as part of closing that Form I am removing the added event handlers amongst which is the following statement that compliments the AddHandler statement above:
   "RemoveHandler Me.ParentSection.Panel.Click, AddressOf Me.Sections.ParentForm.DeselectAllSectionsClick"

So I wasn't expecting any exceptions because stepping through the code I can't see any empty pointers, etc. so I'm a bit confused.

/Michael
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21868144
Michael,

Do you have the full stack trace text for the exception?  When the form is closed, is it disposed?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gem56
ID: 21868840
Sorry, I forgot to say that I get that message only in the IDE Immediate Window and not as a crash.
The Form also closes OK and all looks normal, except for those messages so I was just curious as to whether I should worry about that or not.

/Michael


0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 21869952
I would ignore that exception with a Try/Catch block.
0
 

Author Comment

by:gem56
ID: 21870670
Actually I am using Try/Catch but (stupid me) I forgot to print the ex.Message from the "Catch ex As Exception", I only looked at the output in Immediate Window.

The message in (Catch ex As Exception) has the following message:
"Delegate to an instance method cannot have null 'This'."

That makes sense so, even though I expected all references to be valid, sometimes "Me.Sections.ParentForm' is Nothing and hence the failure.

Thanks for your assistance (as always).

/Michael
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question