Strange Windows Form Behavior

  • Thread starter Thread starter Tyler Foreman
  • Start date Start date
T

Tyler Foreman

Hello,

I have a strange problem that occurs every so often in my
application. It usually takes place when I hide one form
and activate another. What happens is I get the
following exception:

System.ArgumentException occured in
System.Windows.Forms.dll

Additional Information: Invalid Parameter Used.

This occurs sporatically and I haven't found a way yet to
reproduce it reliably. However I just had it occur while
in the debugger and observed some interesting facts:

1. When the debugger stops and highlights the line of
code that the error occured, it is always on the line
where the form is declared and the name of the form
itself is highlighted. For instance, in:

Friend Class Form1

Form1 would be highlighed green by the debugger.

2. It always happens to my startup form (I don't use a
Sub Main). I've tried switching the startup form and the
problems still occurs on the new startup form.

Any ideas or suggestions would be greatly appreciated.

Cheers,
Tyler Foreman
 
-----Original Message-----



What does the callstack show when the error occurs?

Hi,

The callstack shows the following:

<Non-user Code>
Myapp.exe!Myapp.Form1.Main() Line 6 + 0x1d bytes

Also, I seem to be able to make it occur more frequently
in the IDE when I set a breakpoint in one of my
subforms. When I open the subform then close it and
reactivate the main form (Form1), I can get the error to
occur pretty consistently. It seems very strange to me.

Tyler
 
Tyler Foreman said:
The callstack shows the following:

<Non-user Code>
Myapp.exe!Myapp.Form1.Main() Line 6 + 0x1d bytes

Also, I seem to be able to make it occur more frequently
in the IDE when I set a breakpoint in one of my
subforms. When I open the subform then close it and
reactivate the main form (Form1), I can get the error to
occur pretty consistently. It seems very strange to me.

Could you please expand the <Non-user Code>? There's an option when
right-clicking in the callstack window.
 
Hi,
Do U have any code in load or activate events? If yes
check if the code has any problem or any activated object
in these events.
Or the probablity may be, if ur form object is accessing
any other object from DLL, and if that object is
throwing "NULLReferenceException", U will C such errors on
form activate

Mahesh
 
Back
Top