I have never posted in a code forum before, but I am at the end of my rope here...I apologize in advance for the lengthy code sample, but I tried to trim it down:
I have some C# classes that are generated from a schema using the XSD tool. I extend some of the types generated. I have one particular type that has a public ulong property. I am focusing on that property, because the only way I can get rid of the reflection error is if that property is a string instead of another type such as ulong or double, etc. In my example, I include another class that has a string property instead.
The strange thing is that I only get the reflection error when I try to derive my extended type from another class. However, there is no problem if the (derived) type has a string property instead of a ulong. I can however derive from an interface, but that does not suit my purpose. Currently, the only solution I have is to duplicate the code that would be in the base class if I could derive all my types.
The hierachy of my xml is this:
Root->Node1->definitions->variables->[variableBinary|variableDecimal]
As you can see from the example, the only substancial difference between variableBinaryType and variableDecimalType is the public Value property type. The base class from which I am deriving does absolutely nothing in this example. I have tried various attributes on the base class such as [Serializable()], and added an empty constructor, but I still get the reflection error. The only way to avoid it is if variableDecimalType is NOT derived from ANY class
Since the example is so lengthy, please download the zipped project from http://downloads.kinghomesite.com/Test.zip
Here is the really strange part. If you run the example with variableDecimalType actually derived from baseClass, the inner exception says, "There was an error reflecting property 'definitions'.", but I can solve the problem by NOT deriving variableDecimalType, whereas the xml hierachy is Root->Node1->definitions->variables->[variableBinary|variableDecimal].
Why doesn't the inner exception give me more information about what is wrong with variableDecimalType??
Thanks in advance,
sking