[quoted text, click to view] >-----Original Message-----
>Hi !
>
>There is something basic in .NET Remoting that I am
missing:
>
>I have created some simple Remoted type
(MarshalByRefObject ,with
>custom Host), which was referenced by simple client
application.
>During the development all the modules were locally and
when I
>referenced my Remoted assembly by the client it was
copied to my
>Client debug folder. In order to run my application, I
copy my Remoted
>assembly to some other computer. However, when activate
my remoted
>assembly, my local remoted assembly is loaded as well (I
can see it in
>MSVC output window and in process explorer); moreover,
when I delete
>the local remoted assembly the client throws an
exception. My first
>thought was that I have initially to reference the remote
assembly
>remotely, but it seems that in MSVC only Web Services,
which I can
>reference that way. In addition, I am sure that the
remoted instance
>of my assembly is running, so here there is no confusion.
>
>Any help would be appreciated.
>
>Thanks
>
>Jean
>.
>Jean,
I believe that this is the answer you seek. First, let me
make sure I have this correct. You are deploying the same
dll with both your client app and the custom server app.
You want to know "why the client loads the whole dll into
its memory", since the client is using the remoted classes
from the server.
The client loads the whole dll so that it has all of the
class information needed to make the server's copy of the
classes work, in the server's memory space (to be able to
create a proxy instance in the client's memory space that
is used to make calls on the server's remoted object's
public member functions).
You could, feasably build two different dlls, where the
one that the client uses merely has empty (do nothing)
functions (for the public methods). However, be careful
if you do this. Only the public members of a class are
remoted!!! Therefore, any non-public member functions you
may have written actually run from the client's copy (the
proxy) of the class that is loaded into the client's
memory space (and non-public data members will also be
found in the proxy, not at the server). The clients proxy
for this remote object will actually contain all non-
public member method implementations and the non-public
member data.
Let's take a sample to show how wierd this can get. We
develop a remotable class that has a private method that
changes a public data member. We deploy this class in a
dll that both the client and the server apps will have
available on their machines. Next, the client app creates
an instance of our class (a proxy in the client's memory
space) and calls our private method in that class. The
private method will execute at the client machine (because
it is going to run in the proxy). When it gets to the
instruction that assigns a value to the public data
member, this private method will make use of the proxy to
make that assignment at the server's instance of the
remotable object, because that data member was public (and
therefore part of the server's instance of our remotable
class). It can get a lot stranger if you begin to think
about it.
Stick tightly to the KISS Principle (Keep It Simple
Stupid). The purpose of writing software is to simplify
complex operations. Often times, we programmers will make
such a complex solution (being cute) that our solution is
worse than the original problem.
Unless memory at the client machine is a problem, I cannot
imagine why a person would build two different versions of
a dll. I am sure there are other reasons than just
limited memory that may be cause for consideration.
However, maintaining two parallel projects and keeping
changes synchronized in both would be a headache I would
not want, unless it was proved to be absolutely necessary.
I hope this helps,