Re: StackOverflowException with attribute
- From: atlaste <atlaste@xxxxxxxxx>
- Date: 11 May 2007 07:37:17 -0700
I figured that the recursion wasn't infinite (but just deep). Since
semantics of methods (like GetProperties) change that could explain
the behaviour (it worked in 1.1 but not in 2.0). Changing the max
recursion depth not only helps to identify the problem in that
particular case but also helps to solve the special case problem. I
used to have these kind of problems all the time...
However, it seems like it's the GetHashCode that makes the thing
infinite so you were right after all.
I can think of a dozen reasons why they opted for using GetHashCode in
2.0 and not in 1.1. After all, the features of the language evolved. I
would make a new implementation of getHashcode and equals.
Cheers,
Stefan.
On May 11, 4:00 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I don't know what atlaste was trying to indicate by saying to raise the
maximum recursion depth, because in the end, if you have a loop that loops
infinitely, it's always going to be larger than whatever the threshold is.
To me, it would seem that the call to GetProperties on the
TypeDescriptor class is calling back into your GetProperities method, and
it's always going to instantiate another call.
You need to find some way to break this loop. What is it that you are
trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"windsim" <wind...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2CAF805A-EC2C-41E0-A09A-3979D4B5A3A9@xxxxxxxxxxxxxxxx
Thanks guys!
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection globalizedProps;
PropertyDescriptorCollection baseProps =
TypeDescriptor.GetProperties(this, attributes, true);
...
}
I can not set break point at above code line and I think the problem is
maybe TypeDescriptor.GetProperties(...)
The info from call stack looks like a endless loop below :
...
[External Code]
SystemFrameworks.dll!SystemFrameworks.DataObject.GlobalizedObject.GetProperties(System.Attribute[]
attributes = {Dimensions:[1]}) Line 350 + 0xd bytes C#
SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.GetStatefulPropertyDescriptors()
Line 92 + 0x26 bytes C#
SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.GetModulePropertyListCurrent(SystemFrameworks.DataObject.ModuleProperties
mp = {SystemFrameworks.DataObject.DTMProperties}) Line 122 + 0x8 bytes C#
SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.ToString()
Line 350 + 0xb bytes C#
SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.GetHashCode()
Line 313 + 0x7 bytes C#
[External Code]
by the way how to increase this max recursion depth in VS 2005?
--
windsim
"Nicholas Paldino [.NET/C# MVP]" wrote:
windsim,
Well, more likely than not you have a recursive call somewhere (or
something that results in an endless loop of calls). Have you set a
breakpoint and looked a the call stack to see where the calls are
repeating
in a loop?
--
- Nicholas Paldino [.NET/C# MVP]
- m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"windsim" <wind...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ABD92005-416A-4FB2-AB0C-C177F161F535@xxxxxxxxxxxxxxxx
Hi,
I have a project based on .Net 1.1 and VS 2003,now I am trying to
upgrade
it
to .Net 2.0 and VS 2005.The project passes the 'Build Solution',but
When I
start Debug, it suddenly comes StackOverflowException and Debug stops.
The main Exception point is the function below:
public System.ComponentModel.PropertyDescriptorCollection
GetStatefulPropertyDescriptors()
{
DataObject.StatefulPropertyAttribute a = new
StatefulPropertyAttribute();
return this.GetProperties(new Attribute[] { a }); //exception
point
//class System.Attribute that is base class for customer
attributes
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple=false,
Inherited=true)]
public class StatefulPropertyAttribute : Attribute{}
Under .Net 1.1 and VS 2003 there is no problem, no exception for the
function, but why does it come StackOverflowException under .Net 2.0
and
How
to solve it?
--
windsim
.
- Follow-Ups:
- Re: StackOverflowException with attribute
- From: Marc Gravell
- Re: StackOverflowException with attribute
- References:
- Re: StackOverflowException with attribute
- From: Nicholas Paldino [.NET/C# MVP]
- Re: StackOverflowException with attribute
- From: windsim
- Re: StackOverflowException with attribute
- From: Nicholas Paldino [.NET/C# MVP]
- Re: StackOverflowException with attribute
- Prev by Date: Re: Creating a preference window
- Next by Date: Re: Passing XML data as parameter of web service
- Previous by thread: Re: StackOverflowException with attribute
- Next by thread: Re: StackOverflowException with attribute
- Index(es):
Relevant Pages
|