Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Remoting through Activator.Getobject

Posted on 2004-03-21
3
Medium Priority
?
751 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 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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 describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

886 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