Solved

Marshalling

Posted on 2004-08-16
8
386 Views
Last Modified: 2010-04-15
I am experimenting with with 'Marshall by Value' using C#.
I have written a client which uses a interface to remote object
e.g. iRemobj.ReadFile(filename);

Implemantation of this interface I have done on the server side
e.g. class/file name 'RemObj'

Now when I try  'iRemobj.ReadFile(filename)' It executes only when a copy of implementation file 'RemObj.dll' is also available with the client otherwise it generates exceptions as attached below.

So the question is
Is it necessary to have implementation file of remote serializable object with the client ?
If yes then is there any workaround for this ?

Regards
Uttam

[e] An exception occurred.
System.Runtime.Serialization.SerializationException: Cannot find the assembly RemoteObjectMBV, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
[ remaining lines ommited... ]

0
Comment
Question by:uttam80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 19

Expert Comment

by:drichards
ID: 11812822
>> Is it necessary to have implementation file of remote serializable object with the client ?
Yes, that is what marshal-by-value does.  You need to have the implementation of the object on both ends because "marshal-by-value" means "move the whole object to the other end".  So if your client calls a remote method that returns a "marshal-by-value" object, the client must have the executable for that object.  If the client passes a "marshal-by-value" object to the server, the server must have the implementation of the object.

>> If yes then is there any workaround for this ?
No.  Well, actually the workaround is don't use marshal-by-value.
0
 
LVL 7

Expert Comment

by:NipNFriar_Tuck
ID: 11812871
It has been awhile since I used the remoting, however from what I remember you can sirialize an object with a binary serializer.  However, to avoid having to have the assembly in both the client and server you can create an interface that the class implements.  Then you can cast the class to the interface and serialize the interface.  Then only the interface needs to be available to both the client and server.  This is because when an object is deserialized it has to deserialize into the exact object that it was serialized from, at least this is my understanding.

Hope this helps,
nipnfriar_tuck
0
 
LVL 19

Expert Comment

by:drichards
ID: 11813040
You can do custom marshaling to get other results, but if you are doing marshal-by-value you MUST have the complete implementation of the object to make it work because the receiving end must instantiate a copy of the object.  This is useful for the same reason you pass parameters by value rather than by reference in C++ or any other language.  Passing by value means you have a local copy of the value that you can change without affecting the original value.  To do that with an object, though, you need the complete implementation including any supporting objects/functions that the object may use.

Another reason you might marshal by value is that you are going to use the object a lot and it is easier just to send the whole object to the client and do all the processing locally as opposed to sending all the method calls over the wire.  Of course you need to send the object back to the server if the server cares about the modified version of the object.
0
 

Author Comment

by:uttam80
ID: 11820208
Just additional information.

1. Hello nipnfriar_tuck,
On client I am using the interface and the class implementation is on the server. Ofcourse I am also forced to copy the same class implementation on the client and thats the problem I am discussing about.

2. I was comparing this feature with java, I there with RMI ( similar to Remoting in .Net ) does not force serializable class to be physically copied on the client system. On client we can use its interface.

So all these features are very crusial in our decision making on .NET . Any help ?

Uttam


0
 
LVL 7

Accepted Solution

by:
NipNFriar_Tuck earned 50 total points
ID: 11821082
Yes actually, one of the samples that I downloaded when I was looking at remoting as an option for a program I am working on is at http://staff.develop.com/woodring select My .Net samples homepage and then Remoting Events.  This shows both how you can use remoting without having to have the client assembly in the server and how you can do eventing with remoting.  It is a simple example but one that works well.  Basically, here are the steps:

1) Create an assembly that has an interface ( note in the example there is also a "shim" class that is used for eventing but is not needed otherwise ).

2) Create an assembly that references the assembly created in step 1 for the client.

3) Create an assembly that references the assembly created in step 1 for the server.  Also, create a class that inherits from the interface created in step 1.

4) Make the remoting call, something like (this is taken from the example, and ICalc is the interface):

            ICalc c = (ICalc)
                  RemotingServices.Connect(typeof(ICalc), ConfigurationSettings.AppSettings["calcURL"]);

5) Use the instance "c" as defined.


Hope that helps...
nipnfriar_tuck

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Google Directions API to Map URL -C#? 3 46
C# Gridview 1 65
insert value of checklistbox checked 4 39
c#, datatable, aspx 4 19
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question