[Serializable] didn't work only MarshalByRefObject works

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
 
M

Mr. Arnold

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top