Click to See Complete Forum and Search --> : Binding Control to custom properties


Ihawk
September 7th, 2002, 12:58 PM
I've created class with Reflection.Emit. It has some public properties.
Properties are defined as follows:

This is an extract of the my class definition:

propertyBuilder = typeBuilder.DefineProperty(colName,System.Reflection.PropertyAttributes.None,colType, new Type[0]);
methodBuilder = typeBuilder.DefineMethod("get_"+colName, MethodAttributes.Public|MethodAttributes.HideBySig|MethodAttributes.SpecialName,colType, null);
msil = methodBuilder.GetILGenerator();
msil.Emit(OpCodes.Ldarg_0);
msil.Emit(OpCodes.Ldfld, fieldBuilder);
msil.Emit(OpCodes.Ret);
propertyBuilder.SetGetMethod(methodBuilder);
methodBuilder = typeBuilder.DefineMethod("set_"+colName, MethodAttributes.Public|MethodAttributes.HideBySig|MethodAttributes.SpecialName,null, new Type[1]{colType});
msil = methodBuilder.GetILGenerator();
msil.Emit(OpCodes.Ldarg_0);
msil.Emit(OpCodes.Ldarg_1);
msil.Emit(OpCodes.Stfld,fieldBuilder);
msil.Emit(OpCodes.Ret);
propertyBuilder.SetSetMethod(methodBuilder);

After Creating the instance of my dynamic class that includes such property is binded to TextBox:

textBox2.DataBindings.Add("Text",adoTable,"WH_OCRTN");

When I change the property's value like that:
myproperty.SetValue(instance_of_ my_class,value);

The program becomes mad:
After working for a while I recieve the StackOverflow Exception.


I have suspisios that SetValue Method calls OnValueChanged
method of ReflectionPropertyDescriptor. And this method works
with stack wrong.


Has someone any ideas about this program.

And if my suspisions are right how can override the OnValueChaned method.