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,680 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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