Avoid Implementing ISerializable when Inheriting

  • Thread starter Thread starter jehugaleahsa
  • Start date Start date
J

jehugaleahsa

I have a base class for all of my data objects, called DataObject.

The DataObject class has no fields, just methods.

I have serializable derived classes, like Customer, that is looks like
this:

[Serializable]
public class Customer : DataObject
{
/* Uses default ctor */
}

However, every time I try to serialize, I get an exception saying that
DataObject can't be serialized.

I marked it with the Serializable attribute but to no affect.

It looks like .NET wants me to implement ISerializable. But if I do
that, each of my derived classes has to do a lot more work (like
provide a new constructor).

Is there a way to make this work without altering every one of my
derived classes?
 
I have a base class for all of my data objects, called DataObject.

The DataObject class has no fields, just methods.

I have serializable derived classes, like Customer, that is looks like
this:

[Serializable]
public class Customer : DataObject
{
    /* Uses default ctor */

}

However, every time I try to serialize, I get an exception saying that
DataObject can't be serialized.

I marked it with the Serializable attribute but to no affect.

It looks like .NET wants me to implement ISerializable. But if I do
that, each of my derived classes has to do a lot more work (like
provide a new constructor).

Is there a way to make this work without altering every one of my
derived classes?

Um. Nevermind. It would appear that my testing tool was caching my
DLLs. It just suddenly started working. I was starting to think I was
going crazy.
 
I have a base class for all of my data objects, called DataObject.
The DataObject class has no fields, just methods.
I have serializable derived classes, like Customer, that is looks like
this:
[Serializable]
public class Customer : DataObject
{
    /* Uses default ctor */

However, every time I try to serialize, I get an exception saying that
DataObject can't be serialized.
I marked it with the Serializable attribute but to no affect.
It looks like .NET wants me to implement ISerializable. But if I do
that, each of my derived classes has to do a lot more work (like
provide a new constructor).
Is there a way to make this work without altering every one of my
derived classes?

Um. Nevermind. It would appear that my testing tool was caching my
DLLs. It just suddenly started working. I was starting to think I was
going crazy.- Hide quoted text -

- Show quoted text -

It might have something to do with my testing environment (MS'
tester). It appears that if I Debug my tests serialization works. If I
Run my tests they do not.
 
Back
Top