custom control StackOverflowException

  • Thread starter Thread starter éric
  • Start date Start date
É

éric

I have managed to create my custom control and I can add the dll to the
toolbar in a project no problem.

When I add it to the form however I get a StackOverflowException error.

I am not sure where to begin to figure out this error... any ideas?

I have an override for the OnResize event which then calls this.Invalidate()
I thought this was it but when I compile without this.Invalidate() I get the
same errors.

Regards,

éric
 
You've got some sort of recursion going on - probably something in an
eventhandler that in turn causes the even to refire.

-Chris
 
Is there a way for me to step through the code causing the error?

Regards,
éric
 
Actually, what you want to do is to reach the exception under debugger and
look at the Stack window. When doing this, right-click on the stack window
and check "Show non-user code". YOu should be able to see clearly a
repeating pattern of function calls, which will give you an idea of what is
going wrong
 
Hi Alex, thanks for your reply

I am not sure if I understand what you are saying...
The "Call Stack Window" is only available when the application is running in
debug mode.
The problem is I can not even add the control to the form... the error comes
imediatly when I try to place the control on the form.
The control never makes it to the form in the designer and so I can not view
anything in the "Call Stack Window".

What am I missing?

éric
 
Sorry, didn't realize you were talking about the designtime
I think you should be able to launch a second instance of VStudio and attach
to the first one, thus being able to catch the exception in the debugger

éric said:
Hi Alex, thanks for your reply

I am not sure if I understand what you are saying...
The "Call Stack Window" is only available when the application is running in
debug mode.
The problem is I can not even add the control to the form... the error comes
imediatly when I try to place the control on the form.
The control never makes it to the form in the designer and so I can not view
anything in the "Call Stack Window".

What am I missing?

éric

Alex Feinman said:
Actually, what you want to do is to reach the exception under debugger and
look at the Stack window. When doing this, right-click on the stack window
and check "Show non-user code". YOu should be able to see clearly a
repeating pattern of function calls, which will give you an idea of what is
going wrong

éric said:
Is there a way for me to step through the code causing the error?

Regards,
éric

"Chris Tacke, eMVP" <ctacke[at]Open_NET_CF[dot]org> wrote in message
You've got some sort of recursion going on - probably something in an
eventhandler that in turn causes the even to refire.

-Chris


I have managed to create my custom control and I can add the dll
to
the
toolbar in a project no problem.

When I add it to the form however I get a StackOverflowException error.

I am not sure where to begin to figure out this error... any ideas?

I have an override for the OnResize event which then calls
this.Invalidate()
I thought this was it but when I compile without this.Invalidate()
I
get
the
same errors.

Regards,

éric
 
Can I assume that the problem is in or called by my constructor?


Alex Feinman said:
Sorry, didn't realize you were talking about the designtime
I think you should be able to launch a second instance of VStudio and attach
to the first one, thus being able to catch the exception in the debugger

éric said:
Hi Alex, thanks for your reply

I am not sure if I understand what you are saying...
The "Call Stack Window" is only available when the application is
running
in
debug mode.
The problem is I can not even add the control to the form... the error comes
imediatly when I try to place the control on the form.
The control never makes it to the form in the designer and so I can not view
anything in the "Call Stack Window".

What am I missing?

éric

Alex Feinman said:
Actually, what you want to do is to reach the exception under debugger and
look at the Stack window. When doing this, right-click on the stack window
and check "Show non-user code". YOu should be able to see clearly a
repeating pattern of function calls, which will give you an idea of
what
is
going wrong

Is there a way for me to step through the code causing the error?

Regards,
éric

"Chris Tacke, eMVP" <ctacke[at]Open_NET_CF[dot]org> wrote in message
You've got some sort of recursion going on - probably something in an
eventhandler that in turn causes the even to refire.

-Chris


I have managed to create my custom control and I can add the dll to
the
toolbar in a project no problem.

When I add it to the form however I get a StackOverflowException
error.

I am not sure where to begin to figure out this error... any ideas?

I have an override for the OnResize event which then calls
this.Invalidate()
I thought this was it but when I compile without
this.Invalidate()
 
Not necessarily - it could be one of the member functions

éric said:
Can I assume that the problem is in or called by my constructor?


Alex Feinman said:
Sorry, didn't realize you were talking about the designtime
I think you should be able to launch a second instance of VStudio and attach
to the first one, thus being able to catch the exception in the debugger

éric said:
Hi Alex, thanks for your reply

I am not sure if I understand what you are saying...
The "Call Stack Window" is only available when the application is
running
in
debug mode.
The problem is I can not even add the control to the form... the error comes
imediatly when I try to place the control on the form.
The control never makes it to the form in the designer and so I can
not
view
anything in the "Call Stack Window".

What am I missing?

éric

Actually, what you want to do is to reach the exception under
debugger
and
look at the Stack window. When doing this, right-click on the stack window
and check "Show non-user code". YOu should be able to see clearly a
repeating pattern of function calls, which will give you an idea of what
is
going wrong

Is there a way for me to step through the code causing the error?

Regards,
éric

"Chris Tacke, eMVP" <ctacke[at]Open_NET_CF[dot]org> wrote in message
You've got some sort of recursion going on - probably something
in
an
eventhandler that in turn causes the even to refire.

-Chris


I have managed to create my custom control and I can add the
dll
to
the
toolbar in a project no problem.

When I add it to the form however I get a StackOverflowException
error.

I am not sure where to begin to figure out this error... any ideas?

I have an override for the OnResize event which then calls
this.Invalidate()
I thought this was it but when I compile without
this.Invalidate()
I
get
the
same errors.

Regards,

éric
 
I found out what it was but I can't explain it
this line is what messes it up... why? (conditional statement prevents the
StackOverflowException error)
#if !NETCFDESIGNTIME
lblDLStatus.Parent = pnllblDLStatus;
#endif
I put the conditions to avoid the problem in design time... but why does
this cause an error when this line is in the constructor?

Now my problem is 2 fold... without that line the design time does not look
exactly as it should
Second and most important I get the following error when I run the app with
my control:
--------------------------------
TypeLoadException
Could not load type
System.Windows.Froms.Panel from
assembly System.Windows.Forms,
Version = 1.0.5000.0, Culture = neutral
PublickKeyToken=B77A5C561934E089
 
I have these 3 functions when it comes to paint

override OnResize
override OnPaint
pnllblDLStatus_Paint

The thing is, I get the same StackOverflowException even when I remove all
three functions from my code

éric
 
Thanks for your time Alex... I have decided to not use that panel and paint
the item I need.
I don't get errors that way...
Regards,

éric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top