[Mono-dev] AppDomains

Matthijs ter Woord matthijsterwoord at gmail.com
Tue Nov 14 02:43:27 EST 2006


OK. found out how i can work around this mono bug. If I make the method an 
instance member, and derive the object from MarshalByRefObject, it works.



"Matthijs ter Woord" <matthijsterwoord at gmail.com> wrote in message 
news:ejbpjp$bvd$1 at sea.gmane.org...
>I made a testcase, see attached file. The following output is expected:
>
> Foo
> DoTest, 'Hello, World', True
> done
>
>
>
> "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