Solved

Remoting through Activator.Getobject

Posted on 2004-03-21
3
716 Views
Last Modified: 2010-05-18
We are sharing a shared assembly containing mere interfaces between the client and the server.
THe server provides the implementation body for the interfaces.
While invoking the SAO objects from the remote client te following does not work,which is understandable given that abstract classes/interfaces cannot be invoked

                  RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteSharedDef.SharedAsmSAODef),
                        "http://localhost:8657/SAOServer.soap");
            object o=new RemoteSharedDef.SharedAsmSAODef();  


HOwever Activator.GetObject works
object o=Activator.GetObject(typeof(RemoteSharedDef.SharedAsmSAODef),"http://localhost:8657/SAOServer.soap");

So what is the difference in the instantiation mechanism of these 2 options ?

Also though the server registers the SAO as a wellknown object of type SAOServer(which is the implementation class of the interfaces),the client can retrieve an instance by providing the base interface type  the input to GetObject.

So does the mechanism of creating instances through Types(whether it GetObject,CreateInstance etc.) ,work for al lthe child classes too?Although the exact type of thte SAOServer is different as displayed in the debug out put.

0
Comment
Question by:ranadhir
[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
3 Comments
 
LVL 10

Expert Comment

by:ptmcomp
ID: 10643874
The RegisterWllKnownClientType method causes constructor calls to the type to be redirected and create a proxy object.
Activator.GetObject(type, url) explicitly creates a proxy object while further calls to the type's constructor will still create a local instance.
0
 

Author Comment

by:ranadhir
ID: 10646537
In that case can someone specify the particular cases in which the 3 syntax for remote SAO object creation will be used
Activator.CreateObject
RemoteConfiguration.RegisterWellknowClientType(follwed by new)
RemotingServices.Marshal
What is the particular feature in each that makes them suitable to particular situations?
0
 
LVL 10

Accepted Solution

by:
ptmcomp earned 35 total points
ID: 10647479
RegisterWellKnownClientType is best if you don't want to care where the object is running in your code. You can also configure this in the .config-file. Note: For SAO you can only use default constructors. You still should be aware that you're using a remote object which means: Network exceptions can occur, there will be a network overhead for each call.
Activator.GetObject(type,url) is best if your calling the same type hostet on different hosts. E.g. you have to do the same operation on host1 and host2 and may be also locally.

RemotingServices.Marshal is used on server side to dynamically provide an object for a url. It is the complement of Activator.GetObject().
The complement of RegisterWellKnownClientType is RegisterWellKnownServiceType.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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