[Serializable] didn't work only MarshalByRefObject works

  • Thread starter Thread starter Peter Holschbach
  • Start date Start date
P

Peter Holschbach

Hi all,

I have to load a assembly in another AppDomain because I want to unload it
while my application keeps running.
My biggest problem is now that I have to tranfer data between the different
application domains.
As far as I understood types which shall be transfered between different
domains must have the attribute [Serializable] or must be derived from
MarshalByRefObject.
The following code leads to a SerializationException

[Serializable]
public class MyClass
{
public void Execute()
{
Console.WriteLine("Hallo");
}
}

if I use :

public class MyClass : MarshalByRefObject
{
public void Execute()
{
Console.WriteLine("Hallo");
}
}

it works. Is MarshalByRefObject a must ?

thx
Peter
 
Peter Holschbach said:
Hi all,

I have to load a assembly in another AppDomain because I want to unload it
while my application keeps running.
My biggest problem is now that I have to tranfer data between the
different application domains.
As far as I understood types which shall be transfered between different
domains must have the attribute [Serializable] or must be derived from
MarshalByRefObject.
The following code leads to a SerializationException

[Serializable]
public class MyClass
{
public void Execute()
{
Console.WriteLine("Hallo");
}
}

Where is anything in that class Serializable?

Maybe, you need to understand what serialization is about and when to use
it.

http://en.wikipedia.org/wiki/Serialization
http://www.ondotnet.com/pub/a/dotnet/2002/08/26/serialization.html
 
Back
Top