Hello
We're having a issue with a part of our app that is very strange, and
I'm unable to see that it should be possible.
We have:
A collection (ActivityCollec tion) that is inherited from a general,
abstract collection class that implements ITypedList and IBindingList
When the program execute, the ITypedList.GetI temProperties method is
beeing called, but it is beeing called on a uninitialized instance of
the class. I cannot see how that should be possible!
As you can see below, for the sake of testing, we added a private
string called _initializeStat us. In the class definition it is set to
"constructo r not called" and in the constructor it is set to
"constructo r called". Except form that, it's never changed or accessed.
During debugging, we can see that this property is actually
uninitialized, and by that I mean equal to null.
How is this possible? Is there a bug in the .Net framework? Is it
possible to, for example by reflection, bypass the actuall class
initialization?
Is there any known bugs that is able to explain this behaviour?
I may comment that the TypedCollection class is the base class of
hundereds of other classes, all buildt on the same pattern. It's a
large application, and this issue is only seen on two of the
collections. It only occures when the control (a grid) using it is
beeing initialized and it seems like it is never actually used for
anything. However, it does cause problems in the
ITypedList.GetI temProperties as the state of the class is totally
unexpected.
(and it bothers me that something like this at all is possible)
Code extraction of the two classes used is shown below?
[Serializable]
[TypedCollection (typeof(Activit yEntity))]
public class ActivityCollect ion : TypedObjectColl ection{
public ActivityCollect ion() : base(){}
[snip]
[Serializable]
public abstract class TypedObjectColl ection : ObjectCollectio n,
ITypedList, IBindingList{
[NonSerialized]
bool _sortNeeded = true;
private string _initalizeStatu s = "constructo r not called";
private Type _containedType = null;
private static PropertyCompare r _propertyCompar er = new
PropertyCompare r();
private static Hashtable _propertyDescri ptorsCache = new
Hashtable();
protected TypedObjectColl ection(){
_initalizeStatu s = "constructo r called";
[snip]
[Serializable]
public class ObjectCollectio n : CollectionBase, ICloneable{
public ObjectCollectio n(){
}
[snip]
We're having a issue with a part of our app that is very strange, and
I'm unable to see that it should be possible.
We have:
A collection (ActivityCollec tion) that is inherited from a general,
abstract collection class that implements ITypedList and IBindingList
When the program execute, the ITypedList.GetI temProperties method is
beeing called, but it is beeing called on a uninitialized instance of
the class. I cannot see how that should be possible!
As you can see below, for the sake of testing, we added a private
string called _initializeStat us. In the class definition it is set to
"constructo r not called" and in the constructor it is set to
"constructo r called". Except form that, it's never changed or accessed.
During debugging, we can see that this property is actually
uninitialized, and by that I mean equal to null.
How is this possible? Is there a bug in the .Net framework? Is it
possible to, for example by reflection, bypass the actuall class
initialization?
Is there any known bugs that is able to explain this behaviour?
I may comment that the TypedCollection class is the base class of
hundereds of other classes, all buildt on the same pattern. It's a
large application, and this issue is only seen on two of the
collections. It only occures when the control (a grid) using it is
beeing initialized and it seems like it is never actually used for
anything. However, it does cause problems in the
ITypedList.GetI temProperties as the state of the class is totally
unexpected.
(and it bothers me that something like this at all is possible)
Code extraction of the two classes used is shown below?
[Serializable]
[TypedCollection (typeof(Activit yEntity))]
public class ActivityCollect ion : TypedObjectColl ection{
public ActivityCollect ion() : base(){}
[snip]
[Serializable]
public abstract class TypedObjectColl ection : ObjectCollectio n,
ITypedList, IBindingList{
[NonSerialized]
bool _sortNeeded = true;
private string _initalizeStatu s = "constructo r not called";
private Type _containedType = null;
private static PropertyCompare r _propertyCompar er = new
PropertyCompare r();
private static Hashtable _propertyDescri ptorsCache = new
Hashtable();
protected TypedObjectColl ection(){
_initalizeStatu s = "constructo r called";
[snip]
[Serializable]
public class ObjectCollectio n : CollectionBase, ICloneable{
public ObjectCollectio n(){
}
[snip]
Comment