G
Guest
Hi everyone
I have a serious problem with the serilization of an user-defined object in
C#. I would like to serialize an object of class D which inherits from class
C. Class C as well as class D are marked with the compiler-attribute
[Serializable] (see also code-snippet at the end of the message).
It is no problem to serialize a instance of class C, but I got the following
error-message if I try to serialize a instance of class D:
An unhandled exception of type
System.Runtime.Serialization.SerializationException: The type <Namespace>.B
in Assembly <AssemblyName>, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null is not marked as serializes.
The problem I have is, that the variable which causes the Exception is a
member of the base-class C which can be serialized without any problems.
In addition to that, the variable is also marked with the
[NonSerialized]-attribute, so the value of this variable should not be
serialized (see also in the code-snippet).
Thanks for any help!
greetings stephan
Code:
public class A : MarshalByRefObject, IDisposable
{
//some ints, Hashtables, IPAddresses (all
//Serializable)
protected A a
}
public class B : A
{
protected new B a
}
[Serializable]
public class C : MarshalByRefObject, IDisposable
{
[NonSerialized]
protected B a;
//some Guids and longs (all serializable)
}
[Serializable]
public class D: C
{
[NonSerialized]
private static CDBInterface cDBInterface = new CDBInterface();
//some Hashtables (all serializable)
}
I have a serious problem with the serilization of an user-defined object in
C#. I would like to serialize an object of class D which inherits from class
C. Class C as well as class D are marked with the compiler-attribute
[Serializable] (see also code-snippet at the end of the message).
It is no problem to serialize a instance of class C, but I got the following
error-message if I try to serialize a instance of class D:
An unhandled exception of type
System.Runtime.Serialization.SerializationException: The type <Namespace>.B
in Assembly <AssemblyName>, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null is not marked as serializes.
The problem I have is, that the variable which causes the Exception is a
member of the base-class C which can be serialized without any problems.
In addition to that, the variable is also marked with the
[NonSerialized]-attribute, so the value of this variable should not be
serialized (see also in the code-snippet).
Thanks for any help!
greetings stephan
Code:
public class A : MarshalByRefObject, IDisposable
{
//some ints, Hashtables, IPAddresses (all
//Serializable)
protected A a
}
public class B : A
{
protected new B a
}
[Serializable]
public class C : MarshalByRefObject, IDisposable
{
[NonSerialized]
protected B a;
//some Guids and longs (all serializable)
}
[Serializable]
public class D: C
{
[NonSerialized]
private static CDBInterface cDBInterface = new CDBInterface();
//some Hashtables (all serializable)
}