[Mono-dev] AppDomains

Matthijs ter Woord matthijsterwoord at gmail.com
Mon Nov 13 12:58:32 EST 2006


I will try to make a simple test case tomorrow, as I do not a have a mono 
installation available right now. Hopefully something will get more clear 
from my other posts...




"Robert Jordan" <robertj at gmx.net> wrote in message 
news:ejabhq$urt$1 at sea.gmane.org...
> Robert Jordan wrote:
>> Matthijs ter Woord wrote:
>>> Hi,
>>>
>>> I'm the project coordinator of the NApf project. (see
>>> http://www.codeplex.com/NApf)
>>>
>>> For testing our project, we designed a special test harness, which 
>>> starts
>>> small test applications in separate AppDomains. To transfer test states 
>>> back
>>> to the "runner", the child domains get callback methods using the
>>> AppDomain.SetData/GetData methods. Whe the SetData method gets called. I 
>>> get
>>> a very strange exception (all namespaces starting with NApf are ours):
>>>
>>
>> Nothing strange here. You are trying to call SetData on an object whose
>> type is not serializable or not derived from MarshalByRefObject.
>
> I forgot to attach the test case. If it's not similar to yours,
> feel free to create your own test case based on it.
>
> Robert
>
>


--------------------------------------------------------------------------------


> using System;
> using System.Runtime.Serialization;
> using System.Reflection;
>
> public class MainClass
> {
>        public static void Main()
>        {
>                AppDomain appDomain = AppDomain.CreateDomain ("Foo");
>                appDomain.DoCallBack (new CrossAppDomainDelegate 
> (CallBack));
>
>                GetData (appDomain, "key1");
>                GetData (appDomain, "key2");
>                GetData (appDomain, "key3");
>
>                Console.WriteLine ("done");
>        }
>
>        static void GetData(AppDomain dom, string key)
>        {
>                try {
>                        object o = dom.GetData (key);
>                        if (o == null) Console.WriteLine ("{0} is null", 
> key);
>                } catch (SerializationException) {
>                        Console.WriteLine ("{0} failed", key);
>                }
>        }
>
>
>        public static void CallBack ()
>        {
>                Console.WriteLine (AppDomain.CurrentDomain.FriendlyName);
>                AppDomain.CurrentDomain.SetData ("key1", new MyObject ());
>                AppDomain.CurrentDomain.SetData ("key2", new MySerObject 
> ());
>                AppDomain.CurrentDomain.SetData ("key3", new MyMbrObject 
> ());
>        }
> }
>
> public class MyObject
> {
> }
>
> [Serializable]
> public class MySerObject
> {
> }
>
> public class MyMbrObject : MarshalByRefObject
> {
> }
>


--------------------------------------------------------------------------------


> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 






More information about the Mono-devel-list mailing list