Solved

Remoting through Activator.Getobject

Posted on 2004-03-21
3
693 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now