> Would an interface-only assembly in both places also work?

No.  The problem boils down to the fact that GetType() returns 'too much'
information to the serialization infrastructure that's trying to decide what
to do when a client does something like this (using events):

class SomeClient : MarshalByRefObject
{
    void HookUpToServer( IRemoteServer proxy ) {
        proxy.SomeEvent += Notification; // shorthand
    }

    void Notification() {
      // called by server
    }
}

or like this (using an interface):

class SomeClient : : MarshalByRefObject,
                     INotificationSink
{
    void HookUpToServer( IRemoteServer proxy ) {
      proxy.CallMeBackLater(this);
    }

    void INotificationSink.Notification() {
      // called by server
    }
}

In either of the above to scenarios, the key point when the client passes a
reference to itself to the remote server (using either event registration
syntax or just a plain old reference).

In both cases, the act of making that method call (+= or CallMeBackLater) to
the server requires the client-side remoting infrastructure to figure out
how to marshal the reference being passed across to the server.  And that
decision making starts with (metaphorically) a call to GetType, which
returns everything the CLR knows about the client-side object.
Specifically, that it's a concrete class named SomeClient in some namespace
in some assembly; and that it extends MarshalByRefObject.

As a result, this type information is shuffled across to the server, where
its used by the server-side remoting infrastructure to hydrate a proxy
suitable for the server to use to callback to the client.  It's at this
point that the server finds itself trying to load the type information for
"Acme.KillerApp.SomeClient, Acme.Exe, Culture=neutral, Version=0.0.0.0,
PublicKeyToken=null", which is what precipitated the hunt for the client
assembly.

So in the end, regardless of which syntax you use to marshal a reference to
a client-side object over to the server, the server is going to need to be
in full possession of the type information for the concrete type.  So you
either have to put the client assembly on the server where it can be located
via the normal rules for assembly resolution, or you have to insert a layer
of indirection by means of a MBRO shim type that the server *does* know all
about, and that's shared between client & server just like the
interface-related types are shared.

-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsight.com/blogs/mike

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to