Home > Ask the Microsoft .Net Development Experts > C# Development Questions & Answers > Do I need to use an implementation file?
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Do I need to use an implementation file?

Mark Belles EXPERT RESPONSE FROM: Mark Belles

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 31 August 2004
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);

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.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
C#
Top C# expert advice
Escape from mailto:
Can I run a .NET app without installing .NET runtime?
Opening a link with parameters to a new window
Is it possible to open a child form in modal type?
Painting in the non-client area
Global cases to the entire application
Validating the textbox entry for date format
Book on network programming with C#
Calling a secondary UserControl applet

C# programming language
Inside Visual Studio 2010
Mono 2.0 moves .NET apps to Linux - includes migration analyzer
LINQ beyond queries: Strong-typed refection
Assembly versioning in the .NET Framework 2.0
Book excerpt: Creating graphical output using the .NET Compact Framework
Visual Studio 2008 Learning Guide: C# 3.0
Simonyi firm to address divide between domain experts and developers
On Extension Methods in C# and .NET Framework 3.5
Generate RSA public and private keys, export to XML
Book excerpt: Upgrading to Visual Studio 2005

C# Development
Top C# expert advice
Using LoadRunner for testing in .NET
Take care with InitializeComponent
GroupBox inheritance
Escape from mailto:
Windows Forms: Overriding the OnClosing method
Passing data between forms
Can I run a .NET app without installing .NET runtime?
Opening a link with parameters to a new window
Is it possible to open a child form in modal type?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
C#  (SearchWinDevelopment.com)
GLib  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts