[Mono-dev] AppDomains

Matthijs ter Woord matthijsterwoord at gmail.com
Tue Nov 14 02:01:12 EST 2006


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
> 


begin 666 server.cs
M=7-I;F<@4WES=&5M.PT*=7-I;F<@4WES=&5M+E)U;G1I;64N4V5R:6%L:7IA
M=&EO;CL-"G5S:6YG(%-Y<W1E;2Y2969L96-T:6]N.PT*#0IP=6)L:6, at 9&5L
M96=A=&4@=F]I9"!497-T1FEX='5R95)U;D9I;FES:&5D1&5L96=A=&4H<W1R
M:6YG('1E<W12=6Y.86UE+"!B;V]L('!A<W-E9"D[#0IP=6)L:6, at 8VQA<W,@
M36%I;D-L87-S#0I[#0H)"7-T871I8R!V;VED($1O5&5S="AS=')I;F<@=&5S
M=%)U;DYA;64L(&)O;VP@<&%S<V5D*0T*"0E[#0H)"0E#;VYS;VQE+E=R:71E
M3&EN92 at B1&]497-T+" G>S!])RP@>S%](BP@=&5S=%)U;DYA;64L('!A<W-E
M9"D[#0H)"7T-"B @(" @(" @<'5B;&EC('-T871I8R!V;VED($UA:6XH*0T*
M(" @(" @("![#0H@(" @(" @(" @(" @(" @07!P1&]M86EN(&%P<$1O;6%I
M;B ]($%P<$1O;6%I;BY#<F5A=&5$;VUA:6X@*")&;V\B*3L-"B @(" @(" @
M(" @(" @("!A<'!$;VUA:6XN4V5T1&%T82 at B5&AE365T:&]D(BP@;F5W(%1E
M<W1&:7AT=7)E4G5N1FEN:7-H961$96QE9V%T92A$;U1E<W0I*3L-"B @(" @
M(" @(" @(" @("!A<'!$;VUA:6XN1&]#86QL0F%C:R H;F5W($-R;W-S07!P
M1&]M86EN1&5L96=A=&4@*$-A;&Q"86-K*2D[#0H@(" @(" @(" @(" @(" @
M0V]N<V]L92Y7<FET94QI;F4@*")D;VYE(BD[#0H@(" @(" @('T-"@T*(" @
M(" @("!P=6)L:6,@<W1A=&EC('9O:60 at 0V%L;$)A8VL@*"D-"B @(" @(" @
M>PT*(" @(" @(" @(" @(" @($-O;G-O;&4N5W)I=&5,:6YE("A!<'!$;VUA
M:6XN0W5R<F5N=$1O;6%I;BY&<FEE;F1L>4YA;64I.PT*(" @(" @(" @(" @
M(" @("A!<'!$;VUA:6XN0W5R<F5N=$1O;6%I;BY'971$871A*")4:&5-971H
M;V0B*2!A<R!497-T1FEX='5R95)U;D9I;FES:&5D1&5L96=A=&4I*")(96QL
A;RP at 5V]R;&0B+"!T<G5E*3L-"B @(" @(" @?0T*?0T*
`
end





More information about the Mono-devel-list mailing list