Solved

Remoting through Activator.Getobject

Posted on 2004-03-21
3
683 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

11 Experts available now in Live!

Get 1:1 Help Now