One more thing: This is an implementation of the ICustomTypeDescriptor
interface, class name is GlobalizedObject.
Thia whole loop starts when some external code calls the GetHashCode() of my
object of type DTMProperties (inherits from ModuleProperties, inherits from
GlobalizedObject). The stack trace shows below shows that my
ModuleProperties.GetHashCode() method calls ModuleProperties.ToString().
The ToString method calls the GlobalizedObject.GetProperties(...) method in
order to return the name/value pairs of all properties that have a special
attribute.
The code that now executes does the following:
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection globalizedProps;
PropertyDescriptorCollection baseProps =
TypeDescriptor.GetProperties(this, attributes, true);
....
}
The next thing happening according to the stack trace, is that we call into
some external code (probably the TypeDescriptor.GetProperties(...)), and then
we get back into the GetHashCode. Thus an infinite loop.
So the question is whether the .NET 2.0 implementation of
TypeDescriptor.GetProperties(...) calls the GetHashCode method for some
reason now? And was that not the case in 1.1?
Here is a more readable version of my stack trace:
..... (it just repeats itself from here)
[External Code]
SystemFrameworks.DataObject.GlobalizedObject.GetProperties(System.Attribute[] attributes = {Dimensions:[1]})
SystemFrameworks.DataObject.ModuleProperties.GetStatefulPropertyDescriptors()
SystemFrameworks.DataObject.ModuleProperties.GetModulePropertyListCurrent(SystemFrameworks.DataObject.ModuleProperties
mp = {SystemFrameworks.DataObject.DTMProperties})
SystemFrameworks.DataObject.ModuleProperties.ToString()
SystemFrameworks.DataObject.ModuleProperties.GetHashCode()
[External Code]
SystemFrameworks.DataObject.GlobalizedObject.GetProperties(System.Attribute[]
attributes = {Dimensions:[1]})
SystemFrameworks.DataObject.ModuleProperties.GetStatefulPropertyDescriptors()
SystemFrameworks.DataObject.ModuleProperties.GetModulePropertyListCurrent(SystemFrameworks.DataObject.ModuleProperties
mp = {SystemFrameworks.DataObject.DTMProperties})
SystemFrameworks.DataObject.ModuleProperties.ToString()
SystemFrameworks.DataObject.ModuleProperties.GetHashCode()
[External Code]
--
windsim
windsim said:
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 said:
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]
- (e-mail address removed)
windsim said:
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?