Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Remoting through Activator.Getobject

Posted on 2004-03-21
3
Medium Priority
?
738 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 140 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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