I have a Control derived class. When the parent of the control changes the
control's Location property, the stack overflows. I have not found a way to
find out what was on the stack when it does overflow. All I know is that
the program is either stopped due to an exception at the end of Main or has
exited after the Stack Overflow exception. (Both cases are Debug builds
running in the debugger.)
After a lot of trial and error (mostly the latter with a dose of confusion
thrown in), I finally tracked the last statement of mine executed to a line
where, as mentioned, the parent sets the child's location. The location
property is not overridden. I have not subscribed to the child's
LocationChanged event.
I tried full rebuilds in case the executable was corrupt. I tried rebooting
in case Windows was the cause. Neither helped.
Any ideas?
----------
Will Pittenger
E-Mail: mailto:will.pittenger1 at gmail.com
All mail filtered by Qurb ( www.qurb.com) 13 2043
Can you post the complete source code for your custom control, as well as
the code that's being used to instantiate the control and add it to the
container, so we can take a look at it?
--
Tim Wilson
..Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl... I have a Control derived class. When the parent of the control changes
the control's Location property, the stack overflows. I have not found a way
to find out what was on the stack when it does overflow. All I know is that the program is either stopped due to an exception at the end of Main or
has exited after the Stack Overflow exception. (Both cases are Debug builds running in the debugger.)
After a lot of trial and error (mostly the latter with a dose of confusion thrown in), I finally tracked the last statement of mine executed to a
line where, as mentioned, the parent sets the child's location. The location property is not overridden. I have not subscribed to the child's LocationChanged event.
I tried full rebuilds in case the executable was corrupt. I tried
rebooting in case Windows was the cause. Neither helped.
Any ideas? ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
Will Pittenger wrote: I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does overflow. All I know is that the program is either stopped due to an exception at the end of Main or has exited after the Stack Overflow exception. (Both cases are Debug builds running in the debugger.)
After a lot of trial and error (mostly the latter with a dose of confusion thrown in), I finally tracked the last statement of mine executed to a line where, as mentioned, the parent sets the child's location. The location property is not overridden. I have not subscribed to the child's LocationChanged event.
I tried full rebuilds in case the executable was corrupt. I tried rebooting in case Windows was the cause. Neither helped.
Do you have a handler in the child for size or location changing? If
you do, and don't check to see if its the same as it was, you will
cause an infinite loop....
The easiest way to find these is to set a breakpoint in a handler and
see how it got there, or to use the debugging facilities to print out
where you are in the methods.
Matt Any ideas? ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
Not location. Size, yes, but I checked all that. In fact, I did not know
it was the location until later. Nothing should be dealing with the
location except to set it.
----------
Will Pittenger
E-Mail: mailto:will.pittenger1 at gmail.com
All mail filtered by Qurb ( www.qurb.com)
"Matt" <ma********@sprynet.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... Will Pittenger wrote: I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does overflow. All I know is that the program is either stopped due to an exception at the end of Main or has exited after the Stack Overflow exception. (Both cases are Debug builds running in the debugger.)
After a lot of trial and error (mostly the latter with a dose of confusion thrown in), I finally tracked the last statement of mine executed to a line where, as mentioned, the parent sets the child's location. The location property is not overridden. I have not subscribed to the child's LocationChanged event.
I tried full rebuilds in case the executable was corrupt. I tried rebooting in case Windows was the cause. Neither helped.
Do you have a handler in the child for size or location changing? If you do, and don't check to see if its the same as it was, you will cause an infinite loop....
The easiest way to find these is to set a breakpoint in a handler and see how it got there, or to use the debugging facilities to print out where you are in the methods.
Matt Any ideas? ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
Can you post an entire solution containing your custom UserControl, all
supporting custom classes, and a win forms application that demonstrates the
problem at runtime? Ideally if I could have something that I can just unzip,
load into VS, and then hit F5 and watch it blow up then at least I could
start helping after I see the problem. The code that you posted doesn't
compile because it's missing a definition for "memGraphicsDC". And once I
get it to compile I'll need to be able to reproduce the error. So it's for
these two reasons that it would be nice to have an entire solution (zipped
of course).
--
Tim Wilson
..Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message
news:uL**************@tk2msftngp13.phx.gbl... The class has just over 3000 lines. (Several nested classes are
included.) I am attaching the entire class. If I attempt to simplify the file, the problem would probably disappear. It would also take me a while to get
the code to work again. The class is intended to be a header (like the one in Explorer). Normally, the header would always be docked. One of the
nested classes (colDef) represents one of the columns. It serves as the column's definition (hence the name) and paints the column inside the header.
Now, I brought colDef up because I built in a way to allow the column to host a header. This allows for, say a name field, to be split into
several fields. (In that case: First Name, Middle Initial, and Last Name.) When the header is the top level header, it is, as mentioned, docked and there
is no problem. When a column hosts the header, it puts the header into position with the fixChildHeaderPosAndSize member. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:OF****************@TK2MSFTNGP10.phx.gbl... Can you post the complete source code for your custom control, as well
as the code that's being used to instantiate the control and add it to the container, so we can take a look at it?
-- Tim Wilson .Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message news:Or**************@TK2MSFTNGP09.phx.gbl... I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a
way to find out what was on the stack when it does overflow. All I know is
that the program is either stopped due to an exception at the end of Main or has exited after the Stack Overflow exception. (Both cases are Debug
builds running in the debugger.)
After a lot of trial and error (mostly the latter with a dose of confusion thrown in), I finally tracked the last statement of mine executed to a line where, as mentioned, the parent sets the child's location. The
location property is not overridden. I have not subscribed to the child's LocationChanged event.
I tried full rebuilds in case the executable was corrupt. I tried rebooting in case Windows was the cause. Neither helped.
Any ideas? ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
Will Pittenger wrote: Not location. Size, yes, but I checked all that. In fact, I did not know it was the location until later. Nothing should be dealing with the location except to set it.
I'd guess one of two possibilities:
1) The window handle is not valid at the time you try to set the
location
2) The size handler is somehow triggering the location reset. Only a
trace can tell you this one. Set a breakpoint in the size handler and
see when it gets called.
Otherwise, I'd post a message to the form to tell it to resize.
Matt
See below.
----------
Will Pittenger
E-Mail: mailto:will.pittenger1 at gmail.com
All mail filtered by Qurb ( www.qurb.com)
"Matt" <ma********@sprynet.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... 2) The size handler is somehow triggering the location reset. Only a trace can tell you this one. Set a breakpoint in the size handler and see when it gets called.
I know that now. I just do not understand why moving the control would
cause that stack overflow. It sounds like something after the last point I
see in the debugger.
Otherwise, I'd post a message to the form to tell it to resize.
I have no way to get it onto the server. The text file unzipped was only
101K. That was refused until I zipped it. The solution would be much
larger even zipped. (MS must be skimping there.)
The memGraphicsDC class is nothing special. I was actually about to remove
it due to .NET having everything it was meant to do. Replace the
memGraphicsDC parameters with a Graphics object and replace any references
to memDC.DrawSurface with that Graphics object. In the paint handler, use
the paint event argument handler for the Graphics object.
----------
Will Pittenger
E-Mail: mailto:will.pittenger1 at gmail.com
All mail filtered by Qurb ( www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:um**************@TK2MSFTNGP09.phx.gbl... Can you post an entire solution containing your custom UserControl, all supporting custom classes, and a win forms application that demonstrates the problem at runtime? Ideally if I could have something that I can just unzip, load into VS, and then hit F5 and watch it blow up then at least I could start helping after I see the problem. The code that you posted doesn't compile because it's missing a definition for "memGraphicsDC". And once I get it to compile I'll need to be able to reproduce the error. So it's for these two reasons that it would be nice to have an entire solution (zipped of course).
-- Tim Wilson .Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message news:uL**************@tk2msftngp13.phx.gbl... The class has just over 3000 lines. (Several nested classes are included.) I am attaching the entire class. If I attempt to simplify the file, the problem would probably disappear. It would also take me a while to get the code to work again. The class is intended to be a header (like the one in Explorer). Normally, the header would always be docked. One of the nested classes (colDef) represents one of the columns. It serves as the column's definition (hence the name) and paints the column inside the header.
Now, I brought colDef up because I built in a way to allow the column to host a header. This allows for, say a name field, to be split into several fields. (In that case: First Name, Middle Initial, and Last Name.) When the header is the top level header, it is, as mentioned, docked and there is no problem. When a column hosts the header, it puts the header into position with the fixChildHeaderPosAndSize member. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:OF****************@TK2MSFTNGP10.phx.gbl... > Can you post the complete source code for your custom control, as well as > the code that's being used to instantiate the control and add it to the > container, so we can take a look at it? > > -- > Tim Wilson > .Net Compact Framework MVP > > "Will Pittenger" <se***********@see.signature.net> wrote in message > news:Or**************@TK2MSFTNGP09.phx.gbl... >> I have a Control derived class. When the parent of the control >> changes > the >> control's Location property, the stack overflows. I have not found a way > to >> find out what was on the stack when it does overflow. All I know is that >> the program is either stopped due to an exception at the end of Main >> or > has >> exited after the Stack Overflow exception. (Both cases are Debug builds >> running in the debugger.) >> >> After a lot of trial and error (mostly the latter with a dose of >> confusion >> thrown in), I finally tracked the last statement of mine executed to a > line >> where, as mentioned, the parent sets the child's location. The location >> property is not overridden. I have not subscribed to the child's >> LocationChanged event. >> >> I tried full rebuilds in case the executable was corrupt. I tried > rebooting >> in case Windows was the cause. Neither helped. >> >> Any ideas? >> ---------- >> Will Pittenger >> E-Mail: mailto:will.pittenger1 at gmail.com >> All mail filtered by Qurb (www.qurb.com) >> >> > >
Just shoot the zip over to the following email account and I can pick it up
from there. The email address is, of course, mangled.
dllhell [remove] AT hotmail [dot] com
--
Tim Wilson
..Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message
news:e6**************@TK2MSFTNGP15.phx.gbl... I have no way to get it onto the server. The text file unzipped was only 101K. That was refused until I zipped it. The solution would be much larger even zipped. (MS must be skimping there.)
The memGraphicsDC class is nothing special. I was actually about to
remove it due to .NET having everything it was meant to do. Replace the memGraphicsDC parameters with a Graphics object and replace any references to memDC.DrawSurface with that Graphics object. In the paint handler, use the paint event argument handler for the Graphics object. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:um**************@TK2MSFTNGP09.phx.gbl... Can you post an entire solution containing your custom UserControl, all supporting custom classes, and a win forms application that demonstrates the problem at runtime? Ideally if I could have something that I can just unzip, load into VS, and then hit F5 and watch it blow up then at least I could start helping after I see the problem. The code that you posted doesn't compile because it's missing a definition for "memGraphicsDC". And once
I get it to compile I'll need to be able to reproduce the error. So it's
for these two reasons that it would be nice to have an entire solution
(zipped of course).
-- Tim Wilson .Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message news:uL**************@tk2msftngp13.phx.gbl... The class has just over 3000 lines. (Several nested classes are included.) I am attaching the entire class. If I attempt to simplify the file,
the problem would probably disappear. It would also take me a while to get the code to work again. The class is intended to be a header (like the one in Explorer). Normally, the header would always be docked. One of the nested classes (colDef) represents one of the columns. It serves as the column's definition (hence the name) and paints the column inside the header.
Now, I brought colDef up because I built in a way to allow the column
to host a header. This allows for, say a name field, to be split into several fields. (In that case: First Name, Middle Initial, and Last Name.)
When the header is the top level header, it is, as mentioned, docked and
there is no problem. When a column hosts the header, it puts the header into position with the fixChildHeaderPosAndSize member. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:OF****************@TK2MSFTNGP10.phx.gbl... > Can you post the complete source code for your custom control, as
well as > the code that's being used to instantiate the control and add it to
the > container, so we can take a look at it? > > -- > Tim Wilson > .Net Compact Framework MVP > > "Will Pittenger" <se***********@see.signature.net> wrote in message > news:Or**************@TK2MSFTNGP09.phx.gbl... >> I have a Control derived class. When the parent of the control >> changes > the >> control's Location property, the stack overflows. I have not found
a way > to >> find out what was on the stack when it does overflow. All I know is that >> the program is either stopped due to an exception at the end of Main >> or > has >> exited after the Stack Overflow exception. (Both cases are Debug builds >> running in the debugger.) >> >> After a lot of trial and error (mostly the latter with a dose of >> confusion >> thrown in), I finally tracked the last statement of mine executed to
a > line >> where, as mentioned, the parent sets the child's location. The location >> property is not overridden. I have not subscribed to the child's >> LocationChanged event. >> >> I tried full rebuilds in case the executable was corrupt. I tried > rebooting >> in case Windows was the cause. Neither helped. >> >> Any ideas? >> ---------- >> Will Pittenger >> E-Mail: mailto:will.pittenger1 at gmail.com >> All mail filtered by Qurb (www.qurb.com) >> >> > >
You're "memGraphicsDC" class had a good number of method calls that needed
to be translated, using best guess, too. It wasn't as simple as just
swapping out "memGraphicsDC" with Graphics. I also got a few exceptions, all
resource related, when I finally got it to compile and run. Some of the main
reasons why a complete example that just unzips and repros the issue is a
good idea. The issue turns out to be that you were referencing the Size
property from within the "getter" of the Size property definition. So it
just keeps calling itself which eventually results in a stack overflow.
You'll need to change the code to call to the base as shown below.
// Old
public new System.Drawing.Size Size
{
get
{
return Size;
}
set
{
...
}
}
// New
public new System.Drawing.Size Size
{
get
{
return base.Size;
}
set
{
...
}
}
--
Tim Wilson
..Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Actually, I thought up a better way overnight. The form that instantiates the header (rather than another control for now) is quite small. I have difficulty believing you need much more. This class would probably help
as it would create the header within a header that triggered the problem.
That was the header inside the Name column. The main header is docked and does not appear to have an issue with its location property. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:up**************@TK2MSFTNGP10.phx.gbl... Just shoot the zip over to the following email account and I can pick it up from there. The email address is, of course, mangled. dllhell [remove] AT hotmail [dot] com
-- Tim Wilson .Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message news:e6**************@TK2MSFTNGP15.phx.gbl... I have no way to get it onto the server. The text file unzipped was
only 101K. That was refused until I zipped it. The solution would be much larger even zipped. (MS must be skimping there.)
The memGraphicsDC class is nothing special. I was actually about to remove it due to .NET having everything it was meant to do. Replace the memGraphicsDC parameters with a Graphics object and replace any references to memDC.DrawSurface with that Graphics object. In the paint handler, use the paint event argument handler for the Graphics object. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:um**************@TK2MSFTNGP09.phx.gbl... > Can you post an entire solution containing your custom UserControl,
all > supporting custom classes, and a win forms application that > demonstrates > the > problem at runtime? Ideally if I could have something that I can just > unzip, > load into VS, and then hit F5 and watch it blow up then at least I > could > start helping after I see the problem. The code that you posted
doesn't > compile because it's missing a definition for "memGraphicsDC". And
once I > get it to compile I'll need to be able to reproduce the error. So
it's for > these two reasons that it would be nice to have an entire solution (zipped > of course). > > -- > Tim Wilson > .Net Compact Framework MVP > > "Will Pittenger" <se***********@see.signature.net> wrote in message > news:uL**************@tk2msftngp13.phx.gbl... >> The class has just over 3000 lines. (Several nested classes are > included.) >> I am attaching the entire class. If I attempt to simplify the file, the >> problem would probably disappear. It would also take me a while to >> get > the >> code to work again. The class is intended to be a header (like the >> one >> in >> Explorer). Normally, the header would always be docked. One of the > nested >> classes (colDef) represents one of the columns. It serves as the >> column's >> definition (hence the name) and paints the column inside the header. >> >> Now, I brought colDef up because I built in a way to allow the
column to >> host a header. This allows for, say a name field, to be split into > several >> fields. (In that case: First Name, Middle Initial, and Last Name.) When >> the header is the top level header, it is, as mentioned, docked and there > is >> no problem. When a column hosts the header, it puts the header into >> position with the fixChildHeaderPosAndSize member. >> ---------- >> Will Pittenger >> E-Mail: mailto:will.pittenger1 at gmail.com >> All mail filtered by Qurb (www.qurb.com) >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in >> message >> news:OF****************@TK2MSFTNGP10.phx.gbl... >> > Can you post the complete source code for your custom control, as well > as >> > the code that's being used to instantiate the control and add it
to the >> > container, so we can take a look at it? >> > >> > -- >> > Tim Wilson >> > .Net Compact Framework MVP >> > >> > "Will Pittenger" <se***********@see.signature.net> wrote in
message >> > news:Or**************@TK2MSFTNGP09.phx.gbl... >> >> I have a Control derived class. When the parent of the control >> >> changes >> > the >> >> control's Location property, the stack overflows. I have not
found a > way >> > to >> >> find out what was on the stack when it does overflow. All I know >> >> is > that >> >> the program is either stopped due to an exception at the end of >> >> Main >> >> or >> > has >> >> exited after the Stack Overflow exception. (Both cases are Debug > builds >> >> running in the debugger.) >> >> >> >> After a lot of trial and error (mostly the latter with a dose of >> >> confusion >> >> thrown in), I finally tracked the last statement of mine executed >> >> to a >> > line >> >> where, as mentioned, the parent sets the child's location. The > location >> >> property is not overridden. I have not subscribed to the child's >> >> LocationChanged event. >> >> >> >> I tried full rebuilds in case the executable was corrupt. I
tried >> > rebooting >> >> in case Windows was the cause. Neither helped. >> >> >> >> Any ideas? >> >> ---------- >> >> Will Pittenger >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> >> > >> > >> >> >> >> > >
Sorry, I do not know how I missed that. I should have seen that. Why would
that blow up when Location was set?
----------
Will Pittenger
E-Mail: mailto:will.pittenger1 at gmail.com
All mail filtered by Qurb ( www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:Os*************@TK2MSFTNGP09.phx.gbl... You're "memGraphicsDC" class had a good number of method calls that needed to be translated, using best guess, too. It wasn't as simple as just swapping out "memGraphicsDC" with Graphics. I also got a few exceptions, all resource related, when I finally got it to compile and run. Some of the main reasons why a complete example that just unzips and repros the issue is a good idea. The issue turns out to be that you were referencing the Size property from within the "getter" of the Size property definition. So it just keeps calling itself which eventually results in a stack overflow. You'll need to change the code to call to the base as shown below.
// Old public new System.Drawing.Size Size { get { return Size; } set { ... } }
// New public new System.Drawing.Size Size { get { return base.Size; } set { ... } }
-- Tim Wilson .Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Actually, I thought up a better way overnight. The form that instantiates the header (rather than another control for now) is quite small. I have difficulty believing you need much more. This class would probably help as it would create the header within a header that triggered the problem. That was the header inside the Name column. The main header is docked and does not appear to have an issue with its location property. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:up**************@TK2MSFTNGP10.phx.gbl... > Just shoot the zip over to the following email account and I can pick > it > up > from there. The email address is, of course, mangled. > dllhell [remove] AT hotmail [dot] com > > -- > Tim Wilson > .Net Compact Framework MVP > > "Will Pittenger" <se***********@see.signature.net> wrote in message > news:e6**************@TK2MSFTNGP15.phx.gbl... >> I have no way to get it onto the server. The text file unzipped was only >> 101K. That was refused until I zipped it. The solution would be much >> larger even zipped. (MS must be skimping there.) >> >> The memGraphicsDC class is nothing special. I was actually about to > remove >> it due to .NET having everything it was meant to do. Replace the >> memGraphicsDC parameters with a Graphics object and replace any >> references >> to memDC.DrawSurface with that Graphics object. In the paint handler, >> use >> the paint event argument handler for the Graphics object. >> ---------- >> Will Pittenger >> E-Mail: mailto:will.pittenger1 at gmail.com >> All mail filtered by Qurb (www.qurb.com) >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in >> message >> news:um**************@TK2MSFTNGP09.phx.gbl... >> > Can you post an entire solution containing your custom UserControl, all >> > supporting custom classes, and a win forms application that >> > demonstrates >> > the >> > problem at runtime? Ideally if I could have something that I can >> > just >> > unzip, >> > load into VS, and then hit F5 and watch it blow up then at least I >> > could >> > start helping after I see the problem. The code that you posted doesn't >> > compile because it's missing a definition for "memGraphicsDC". And once > I >> > get it to compile I'll need to be able to reproduce the error. So it's > for >> > these two reasons that it would be nice to have an entire solution > (zipped >> > of course). >> > >> > -- >> > Tim Wilson >> > .Net Compact Framework MVP >> > >> > "Will Pittenger" <se***********@see.signature.net> wrote in message >> > news:uL**************@tk2msftngp13.phx.gbl... >> >> The class has just over 3000 lines. (Several nested classes are >> > included.) >> >> I am attaching the entire class. If I attempt to simplify the >> >> file, > the >> >> problem would probably disappear. It would also take me a while to >> >> get >> > the >> >> code to work again. The class is intended to be a header (like the >> >> one >> >> in >> >> Explorer). Normally, the header would always be docked. One of >> >> the >> > nested >> >> classes (colDef) represents one of the columns. It serves as the >> >> column's >> >> definition (hence the name) and paints the column inside the >> >> header. >> >> >> >> Now, I brought colDef up because I built in a way to allow the column > to >> >> host a header. This allows for, say a name field, to be split into >> > several >> >> fields. (In that case: First Name, Middle Initial, and Last Name.) > When >> >> the header is the top level header, it is, as mentioned, docked and > there >> > is >> >> no problem. When a column hosts the header, it puts the header >> >> into >> >> position with the fixChildHeaderPosAndSize member. >> >> ---------- >> >> Will Pittenger >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in >> >> message >> >> news:OF****************@TK2MSFTNGP10.phx.gbl... >> >> > Can you post the complete source code for your custom control, as > well >> > as >> >> > the code that's being used to instantiate the control and add it to > the >> >> > container, so we can take a look at it? >> >> > >> >> > -- >> >> > Tim Wilson >> >> > .Net Compact Framework MVP >> >> > >> >> > "Will Pittenger" <se***********@see.signature.net> wrote in message >> >> > news:Or**************@TK2MSFTNGP09.phx.gbl... >> >> >> I have a Control derived class. When the parent of the control >> >> >> changes >> >> > the >> >> >> control's Location property, the stack overflows. I have not found > a >> > way >> >> > to >> >> >> find out what was on the stack when it does overflow. All I >> >> >> know >> >> >> is >> > that >> >> >> the program is either stopped due to an exception at the end of >> >> >> Main >> >> >> or >> >> > has >> >> >> exited after the Stack Overflow exception. (Both cases are >> >> >> Debug >> > builds >> >> >> running in the debugger.) >> >> >> >> >> >> After a lot of trial and error (mostly the latter with a dose of >> >> >> confusion >> >> >> thrown in), I finally tracked the last statement of mine >> >> >> executed >> >> >> to > a >> >> > line >> >> >> where, as mentioned, the parent sets the child's location. The >> > location >> >> >> property is not overridden. I have not subscribed to the >> >> >> child's >> >> >> LocationChanged event. >> >> >> >> >> >> I tried full rebuilds in case the executable was corrupt. I tried >> >> > rebooting >> >> >> in case Windows was the cause. Neither helped. >> >> >> >> >> >> Any ideas? >> >> >> ---------- >> >> >> Will Pittenger >> >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> >> >> >> >> >> > >> > >> >> > >
I'm not sure. I didn't look into why the Size property was being called, I
just went to the point of locating the recursion that was happening within
the Size property itself.
--
Tim Wilson
..Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... Sorry, I do not know how I missed that. I should have seen that. Why
would that blow up when Location was set? ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:Os*************@TK2MSFTNGP09.phx.gbl... You're "memGraphicsDC" class had a good number of method calls that
needed to be translated, using best guess, too. It wasn't as simple as just swapping out "memGraphicsDC" with Graphics. I also got a few exceptions, all resource related, when I finally got it to compile and run. Some of the main reasons why a complete example that just unzips and repros the issue is
a good idea. The issue turns out to be that you were referencing the Size property from within the "getter" of the Size property definition. So it just keeps calling itself which eventually results in a stack overflow. You'll need to change the code to call to the base as shown below.
// Old public new System.Drawing.Size Size { get { return Size; } set { ... } }
// New public new System.Drawing.Size Size { get { return base.Size; } set { ... } }
-- Tim Wilson .Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Actually, I thought up a better way overnight. The form that instantiates the header (rather than another control for now) is quite small. I
have difficulty believing you need much more. This class would probably
help as it would create the header within a header that triggered the problem. That was the header inside the Name column. The main header is docked and does not appear to have an issue with its location property. ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:up**************@TK2MSFTNGP10.phx.gbl... > Just shoot the zip over to the following email account and I can pick > it > up > from there. The email address is, of course, mangled. > dllhell [remove] AT hotmail [dot] com > > -- > Tim Wilson > .Net Compact Framework MVP > > "Will Pittenger" <se***********@see.signature.net> wrote in message > news:e6**************@TK2MSFTNGP15.phx.gbl... >> I have no way to get it onto the server. The text file unzipped was only >> 101K. That was refused until I zipped it. The solution would be
much >> larger even zipped. (MS must be skimping there.) >> >> The memGraphicsDC class is nothing special. I was actually about to > remove >> it due to .NET having everything it was meant to do. Replace the >> memGraphicsDC parameters with a Graphics object and replace any >> references >> to memDC.DrawSurface with that Graphics object. In the paint
handler, >> use >> the paint event argument handler for the Graphics object. >> ---------- >> Will Pittenger >> E-Mail: mailto:will.pittenger1 at gmail.com >> All mail filtered by Qurb (www.qurb.com) >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in >> message >> news:um**************@TK2MSFTNGP09.phx.gbl... >> > Can you post an entire solution containing your custom
UserControl, all >> > supporting custom classes, and a win forms application that >> > demonstrates >> > the >> > problem at runtime? Ideally if I could have something that I can >> > just >> > unzip, >> > load into VS, and then hit F5 and watch it blow up then at least I >> > could >> > start helping after I see the problem. The code that you posted doesn't >> > compile because it's missing a definition for "memGraphicsDC". And once > I >> > get it to compile I'll need to be able to reproduce the error. So it's > for >> > these two reasons that it would be nice to have an entire solution > (zipped >> > of course). >> > >> > -- >> > Tim Wilson >> > .Net Compact Framework MVP >> > >> > "Will Pittenger" <se***********@see.signature.net> wrote in
message >> > news:uL**************@tk2msftngp13.phx.gbl... >> >> The class has just over 3000 lines. (Several nested classes are >> > included.) >> >> I am attaching the entire class. If I attempt to simplify the >> >> file, > the >> >> problem would probably disappear. It would also take me a while
to >> >> get >> > the >> >> code to work again. The class is intended to be a header (like
the >> >> one >> >> in >> >> Explorer). Normally, the header would always be docked. One of >> >> the >> > nested >> >> classes (colDef) represents one of the columns. It serves as the >> >> column's >> >> definition (hence the name) and paints the column inside the >> >> header. >> >> >> >> Now, I brought colDef up because I built in a way to allow the column > to >> >> host a header. This allows for, say a name field, to be split
into >> > several >> >> fields. (In that case: First Name, Middle Initial, and Last
Name.) > When >> >> the header is the top level header, it is, as mentioned, docked
and > there >> > is >> >> no problem. When a column hosts the header, it puts the header >> >> into >> >> position with the fixChildHeaderPosAndSize member. >> >> ---------- >> >> Will Pittenger >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote
in >> >> message >> >> news:OF****************@TK2MSFTNGP10.phx.gbl... >> >> > Can you post the complete source code for your custom control,
as > well >> > as >> >> > the code that's being used to instantiate the control and add
it to > the >> >> > container, so we can take a look at it? >> >> > >> >> > -- >> >> > Tim Wilson >> >> > .Net Compact Framework MVP >> >> > >> >> > "Will Pittenger" <se***********@see.signature.net> wrote in message >> >> > news:Or**************@TK2MSFTNGP09.phx.gbl... >> >> >> I have a Control derived class. When the parent of the
control >> >> >> changes >> >> > the >> >> >> control's Location property, the stack overflows. I have not found > a >> > way >> >> > to >> >> >> find out what was on the stack when it does overflow. All I >> >> >> know >> >> >> is >> > that >> >> >> the program is either stopped due to an exception at the end
of >> >> >> Main >> >> >> or >> >> > has >> >> >> exited after the Stack Overflow exception. (Both cases are >> >> >> Debug >> > builds >> >> >> running in the debugger.) >> >> >> >> >> >> After a lot of trial and error (mostly the latter with a dose
of >> >> >> confusion >> >> >> thrown in), I finally tracked the last statement of mine >> >> >> executed >> >> >> to > a >> >> > line >> >> >> where, as mentioned, the parent sets the child's location.
The >> > location >> >> >> property is not overridden. I have not subscribed to the >> >> >> child's >> >> >> LocationChanged event. >> >> >> >> >> >> I tried full rebuilds in case the executable was corrupt. I tried >> >> > rebooting >> >> >> in case Windows was the cause. Neither helped. >> >> >> >> >> >> Any ideas? >> >> >> ---------- >> >> >> Will Pittenger >> >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> >> >> >> >> >> > >> > >> >> > >
The more I think about it, it depends on how much .NET relies on Win32 calls
to do simple things. (I worked with MFC/C++ for close to a decade before
getting C#.) Windows stores rectangles using the lower right corner rather
than the size. If Windows is relying on .NET to track that rect, .NET is
going to use the Size property. Does that make sense?
----------
Will Pittenger
E-Mail: mailto:will.pittenger1 at gmail.com
All mail filtered by Qurb ( www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:up**************@TK2MSFTNGP10.phx.gbl... I'm not sure. I didn't look into why the Size property was being called, I just went to the point of locating the recursion that was happening within the Size property itself.
-- Tim Wilson .Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... Sorry, I do not know how I missed that. I should have seen that. Why would that blow up when Location was set? ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com)
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message news:Os*************@TK2MSFTNGP09.phx.gbl... > You're "memGraphicsDC" class had a good number of method calls that needed > to be translated, using best guess, too. It wasn't as simple as just > swapping out "memGraphicsDC" with Graphics. I also got a few > exceptions, > all > resource related, when I finally got it to compile and run. Some of the > main > reasons why a complete example that just unzips and repros the issue is a > good idea. The issue turns out to be that you were referencing the Size > property from within the "getter" of the Size property definition. So > it > just keeps calling itself which eventually results in a stack overflow. > You'll need to change the code to call to the base as shown below. > > // Old > public new System.Drawing.Size Size > { > get > { > return Size; > } > set > { > ... > } > } > > // New > public new System.Drawing.Size Size > { > get > { > return base.Size; > } > set > { > ... > } > } > > -- > Tim Wilson > .Net Compact Framework MVP > > "Will Pittenger" <se***********@see.signature.net> wrote in message > news:%2****************@TK2MSFTNGP10.phx.gbl... >> Actually, I thought up a better way overnight. The form that >> instantiates >> the header (rather than another control for now) is quite small. I have >> difficulty believing you need much more. This class would probably help > as >> it would create the header within a header that triggered the problem. > That >> was the header inside the Name column. The main header is docked and >> does >> not appear to have an issue with its location property. >> ---------- >> Will Pittenger >> E-Mail: mailto:will.pittenger1 at gmail.com >> All mail filtered by Qurb (www.qurb.com) >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in >> message >> news:up**************@TK2MSFTNGP10.phx.gbl... >> > Just shoot the zip over to the following email account and I can >> > pick >> > it >> > up >> > from there. The email address is, of course, mangled. >> > dllhell [remove] AT hotmail [dot] com >> > >> > -- >> > Tim Wilson >> > .Net Compact Framework MVP >> > >> > "Will Pittenger" <se***********@see.signature.net> wrote in message >> > news:e6**************@TK2MSFTNGP15.phx.gbl... >> >> I have no way to get it onto the server. The text file unzipped >> >> was > only >> >> 101K. That was refused until I zipped it. The solution would be much >> >> larger even zipped. (MS must be skimping there.) >> >> >> >> The memGraphicsDC class is nothing special. I was actually about >> >> to >> > remove >> >> it due to .NET having everything it was meant to do. Replace the >> >> memGraphicsDC parameters with a Graphics object and replace any >> >> references >> >> to memDC.DrawSurface with that Graphics object. In the paint handler, >> >> use >> >> the paint event argument handler for the Graphics object. >> >> ---------- >> >> Will Pittenger >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in >> >> message >> >> news:um**************@TK2MSFTNGP09.phx.gbl... >> >> > Can you post an entire solution containing your custom UserControl, > all >> >> > supporting custom classes, and a win forms application that >> >> > demonstrates >> >> > the >> >> > problem at runtime? Ideally if I could have something that I can >> >> > just >> >> > unzip, >> >> > load into VS, and then hit F5 and watch it blow up then at least >> >> > I >> >> > could >> >> > start helping after I see the problem. The code that you posted > doesn't >> >> > compile because it's missing a definition for "memGraphicsDC". >> >> > And > once >> > I >> >> > get it to compile I'll need to be able to reproduce the error. So > it's >> > for >> >> > these two reasons that it would be nice to have an entire >> >> > solution >> > (zipped >> >> > of course). >> >> > >> >> > -- >> >> > Tim Wilson >> >> > .Net Compact Framework MVP >> >> > >> >> > "Will Pittenger" <se***********@see.signature.net> wrote in message >> >> > news:uL**************@tk2msftngp13.phx.gbl... >> >> >> The class has just over 3000 lines. (Several nested classes are >> >> > included.) >> >> >> I am attaching the entire class. If I attempt to simplify the >> >> >> file, >> > the >> >> >> problem would probably disappear. It would also take me a while to >> >> >> get >> >> > the >> >> >> code to work again. The class is intended to be a header (like the >> >> >> one >> >> >> in >> >> >> Explorer). Normally, the header would always be docked. One of >> >> >> the >> >> > nested >> >> >> classes (colDef) represents one of the columns. It serves as >> >> >> the >> >> >> column's >> >> >> definition (hence the name) and paints the column inside the >> >> >> header. >> >> >> >> >> >> Now, I brought colDef up because I built in a way to allow the > column >> > to >> >> >> host a header. This allows for, say a name field, to be split into >> >> > several >> >> >> fields. (In that case: First Name, Middle Initial, and Last Name.) >> > When >> >> >> the header is the top level header, it is, as mentioned, docked and >> > there >> >> > is >> >> >> no problem. When a column hosts the header, it puts the header >> >> >> into >> >> >> position with the fixChildHeaderPosAndSize member. >> >> >> ---------- >> >> >> Will Pittenger >> >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> >> >> "Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in >> >> >> message >> >> >> news:OF****************@TK2MSFTNGP10.phx.gbl... >> >> >> > Can you post the complete source code for your custom control, as >> > well >> >> > as >> >> >> > the code that's being used to instantiate the control and add it > to >> > the >> >> >> > container, so we can take a look at it? >> >> >> > >> >> >> > -- >> >> >> > Tim Wilson >> >> >> > .Net Compact Framework MVP >> >> >> > >> >> >> > "Will Pittenger" <se***********@see.signature.net> wrote in > message >> >> >> > news:Or**************@TK2MSFTNGP09.phx.gbl... >> >> >> >> I have a Control derived class. When the parent of the control >> >> >> >> changes >> >> >> > the >> >> >> >> control's Location property, the stack overflows. I have not > found >> > a >> >> > way >> >> >> > to >> >> >> >> find out what was on the stack when it does overflow. All I >> >> >> >> know >> >> >> >> is >> >> > that >> >> >> >> the program is either stopped due to an exception at the end of >> >> >> >> Main >> >> >> >> or >> >> >> > has >> >> >> >> exited after the Stack Overflow exception. (Both cases are >> >> >> >> Debug >> >> > builds >> >> >> >> running in the debugger.) >> >> >> >> >> >> >> >> After a lot of trial and error (mostly the latter with a dose of >> >> >> >> confusion >> >> >> >> thrown in), I finally tracked the last statement of mine >> >> >> >> executed >> >> >> >> to >> > a >> >> >> > line >> >> >> >> where, as mentioned, the parent sets the child's location. The >> >> > location >> >> >> >> property is not overridden. I have not subscribed to the >> >> >> >> child's >> >> >> >> LocationChanged event. >> >> >> >> >> >> >> >> I tried full rebuilds in case the executable was corrupt. I > tried >> >> >> > rebooting >> >> >> >> in case Windows was the cause. Neither helped. >> >> >> >> >> >> >> >> Any ideas? >> >> >> >> ---------- >> >> >> >> Will Pittenger >> >> >> >> E-Mail: mailto:will.pittenger1 at gmail.com >> >> >> >> All mail filtered by Qurb (www.qurb.com) >> >> >> >> >> >> >> >> >> >> >> > >> >> >> > >> >> >> >> >> >> >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> >> > >> > >> >> >> > >
I don't think that the problem lies with the way .NET is doing things. If
you take, for example, the following code, create an instance of the
MyButton class, and then set the Location property, the Size property is not
called. You can set breakpoints in both the set and get and neither will be
called. Maybe there is something else in your code that is causing the call
to the Size property.
public class MyButton : System.Windows.Forms.Button
{
public new Size Size
{
get
{
return base.Size;
}
set
{
base.Size = value;
}
}
}
--
Tim Wilson
..Net Compact Framework MVP
"Will Pittenger" <se***********@see.signature.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... The more I think about it, it depends on how much .NET relies on Win32
calls to do simple things. (I worked with MFC/C++ for close to a decade before getting C#.) Windows stores rectangles using the lower right corner
rather than the size. If Windows is relying on .NET to track that rect, .NET is going to use the Size property. Does that make sense? ---------- Will Pittenger E-Mail: mailto:will.pittenger1 at gmail.com All mail filtered by Qurb (www.qurb.com) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrew |
last post by:
Last night I was reading about implementing my own stack. The example
given pushes items on and off the stack at the start and end of each
procedure (ie. in a std module). What's not so clear is...
|
by: Will Pittenger |
last post by:
I have a Control derived class. When the parent of the control changes the
control's Location property, the stack overflows. I have not found a way to
find out what was on the stack when it does...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |