Yeah, I guess.  It just feels like the AppDomain class needs a 
DoCallbackByReference(ref CrossAppDomainDelegate) method, or something like that, 
which passes the delegate (and its object) both directions on the wire.

I was a bit dismayed to have to completely redesign several classes in order to 
workaround this issue -- I didn't want to take the perf hit of simply deriving Foo 
from MBRO (in reality, the code in my Foo.CallbackImplementation needs to access a lot 
of member data, each of which would require a roundtrip back to the first appdomain).

So I had to engineer a whole new MBRO-derived class to hold the results of this little 
operation, instantiate it in the 2nd appdomain via CreateInstanceAndUnwrap, etc etc.

The end result is, I'm no longer using AppDomain.DoCallback at all.  (And I probably 
never will again, it's just too restrictive.)

But thanks for the sanity-check, Charlie...!
-S


On Sun, 15 Dec 2002 12:25:24 -0800, Charlie Poole <[EMAIL PROTECTED]> wrote:

>To have your object - and not a different one - _refered_ to by the
>other app domain, you have to pass it by _reference_
>
>You can either extend MarshalByRefObject or implement your own
>marshalling. :-)
>
>Charlie Poole
>[EMAIL PROTECTED]
>www.pooleconsulting.com
>www.charliepoole.org
>
>
>
>> -----Original Message-----
>> From: Moderated discussion of advanced .NET topics.
>> [mailto:[EMAIL PROTECTED]]On Behalf Of Shawn A. Van
>> Ness
>> Sent: Sunday, December 15, 2002 12:59 AM
>> To: [EMAIL PROTECTED]
>> Subject: [ADVANCED-DOTNET] AppDomain.DoCallback(CrossAppDomainDelegate)
>> bug?
>>
>>
>> v1.0.3705...  I just tried sending a delegate, bound to a
>> serializable/mbv instance, to AppDomain.DoCallback.  I was
>> surprised to find that my object was only transmitted [in] to the
>> secondary appdomain, not [in,out].
>>
>> Is there no way to return any info from AppDomain.DoCallback (w/o
>> having Foo extend MarshalByRefObject)?
>>
>> Is this behaviour by design?  It feels unintuitive...  am I
>> missing something?
>> -S
>>
>> using System;
>>
>> [Serializable]
>> class Foo
>> {
>>     public int memberVar = 7;
>>
>>     public void CallbackImplementation()
>>     {
>>         this.memberVar = 13;
>>     }
>> }
>>
>> class MainModule
>> {
>>     static void Main()
>>     {
>>         Foo foo = new Foo();
>>
>>         AppDomain secondaryDomain =
>>             AppDomain.CreateDomain( "secondary domain");
>>
>>         // 'foo' will be serialized and sent across the wire to
>> secondaryDomain,
>>         // where 'foo.memberVar' will be modified.  but how to
>> communicate the
>>         // new value back to our side of the fence?
>>         secondaryDomain.DoCallBack(
>>             new CrossAppDomainDelegate(foo.CallbackImplementation));
>>
>>         Console.WriteLine(foo.memberVar);
>>         // still 7! expected: 13?
>>     }
>> }
>>
>>
>> Cheers,
>> -Shawn
>> http://www.arithex.com/
>>
>> You can read messages from the Advanced DOTNET archive,
>> unsubscribe from Advanced DOTNET, or
>> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>>
>>
>
>You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
>DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to