T
TEK
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 (ActivityCollection) that is inherited from a general,
abstract collection class that implements ITypedList and IBindingList
When the program execute, the ITypedList.GetItemProperties 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 _initializeStatus. In the class definition it is set to
"constructor not called" and in the constructor it is set to
"constructor 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.GetItemProperties 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(ActivityEntity))]
public class ActivityCollection : TypedObjectCollection{
public ActivityCollection() : base(){}
[snip]
[Serializable]
public abstract class TypedObjectCollection : ObjectCollection,
ITypedList, IBindingList{
[NonSerialized]
bool _sortNeeded = true;
private string _initalizeStatus = "constructor not called";
private Type _containedType = null;
private static PropertyComparer _propertyComparer = new
PropertyComparer();
private static Hashtable _propertyDescriptorsCache = new
Hashtable();
protected TypedObjectCollection(){
_initalizeStatus = "constructor called";
[snip]
[Serializable]
public class ObjectCollection : CollectionBase, ICloneable{
public ObjectCollection(){
}
[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 (ActivityCollection) that is inherited from a general,
abstract collection class that implements ITypedList and IBindingList
When the program execute, the ITypedList.GetItemProperties 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 _initializeStatus. In the class definition it is set to
"constructor not called" and in the constructor it is set to
"constructor 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.GetItemProperties 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(ActivityEntity))]
public class ActivityCollection : TypedObjectCollection{
public ActivityCollection() : base(){}
[snip]
[Serializable]
public abstract class TypedObjectCollection : ObjectCollection,
ITypedList, IBindingList{
[NonSerialized]
bool _sortNeeded = true;
private string _initalizeStatus = "constructor not called";
private Type _containedType = null;
private static PropertyComparer _propertyComparer = new
PropertyComparer();
private static Hashtable _propertyDescriptorsCache = new
Hashtable();
protected TypedObjectCollection(){
_initalizeStatus = "constructor called";
[snip]
[Serializable]
public class ObjectCollection : CollectionBase, ICloneable{
public ObjectCollection(){
}
[snip]