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,683 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
  • 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
Technology Partners: 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 Publish Error 2 44
Visual studio 2015 1 34
Get month and date in a format 4 45
Create simple VB.net Add-in for Excel in Office 365 2 20
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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