By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Implementation 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. So the question is:
Is it necessary to have an implementation file of remote serializable object with the client? If yes, then is there any workaround for this?
The exception you are experiencing is by design. Remoting a MarshallByValue object requires the entire object to be serialized to the client. This would require the implementation of the interface to be loaded by the client. If you want to deploy a common dll that contains the interface only to the client, simply inherit your object from MarshallByRef object instead. Then create a server side dll that implements the interface and provides the implementation code. Once you have created the common dll containing the interface definition, and the server side implementation using a class that implements the interface, simply marshal the server side class. You may either marshall a specific instance of the class using RemotingServices.Marshal(), or marshal the type using the RemotingConfiguration.RegisterWellKnownServiceType() method.
When you use remoting to connect to a MarshallByRef object, you are working with a proxy object that passes the calls back to the server for processing. Since your specific implementation of the interface exists on the server, the proxy calls on the interface will be passed back and performed on the server object. Determining the type of deployment you want, and the type of work that will be done by the remote object will help you determine which route you should take. MarshallByValue objects are usually used for quick one off functionality that can be quickly remoted to the client. MarshallByRef objects are more usefull for longer operations where specific objects need to be remoted by the server. For example if you wanted to create an object on the server, connect it to a database or do some initialization on the object that only needs to be done once and can then be used over and over then MarshallByRef objects may be more suitable for your task.
Using the MSDN Library help files, check out this link. ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconremotableobjects.htm for more information about the differences between MarshallByValue and MarshallByRef objects. Searching Google for Remoting examples should yield you a great many number of hits for usefull articles and examples.
Dig Deeper on C# programming language
Related Q&A from Mark Belles
This expert response shows how to access VB .NET Windows control on the client side.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.