Still trying to figure out how to get around this issue, any ideas anyone ?


-----Original Message-----
From: Abdulla, Jehangir 
Sent: Thursday, November 07, 2002 4:42 PM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Getting the Real Object registered on the
Remoting server so that I could get to its ObjRef


Don't know if this is a pretty simple question but I have spent a couple of hours in 
trying to figure this out

I have a method on the server side that returns the ObjRef of a Singleton. This method 
checks if the Singleton is registered already with the Remoting Infrastructure, if it 
is, it returns the ObjRef, if not it creates the object, registers it with the 
remoting infrastructure and returns the ObjRef.

The latter part i.e. creating the object and returning the ObjRef is pretty simple, 
what I'm struggling with is returning the ObjRef if the object is already registered 
as a singleton.
Here's what I have done so far. 

public ObjRef GetRemoteObject(string friendlyName)
{
                        string assemblyName = String.Empty;
                        string className = String.Empty;
                        // look up the type name and the assembly name in the 
                        // database based on the friendly name passed in
                        // see if object is registered, if it is return object
                        WellKnownServiceTypeEntry[] wstes = 
                                
RemotingConfiguration.GetRegisteredWellKnownServiceTypes();

                        foreach(WellKnownServiceTypeEntry wste in wstes)
                        {
                                if(wste.ObjectType.FullName == className + ", " + 
assemblyName)
                                        
                                        // here I need to return the ObjRef of the 
object if it is already registered
                                        // any ideas on how I could do that ?
                                        return a new ObjRef that points to the same 
object or return the same ObjRef
                                        
                                        // Any ideas on how to get the ObjRef of the 
existing object thats registered.
                                        // If somehow I could get access to the Real 
Object itself from the                                                         // 
WellKnownServiceTypeEntry, I could use something like this to get a new                
                               // ObjRef
                                        // ObjRef newObjRef = new 
ObjRef(howdoIGetAccessToTheObject, wste.ObjectType);  
                                        // return newObjRef;
                        }

                        MarshalByRefObject obj = 
(MarshalByRefObject)Activator.CreateInstance
                                                                                
(assemblyName,typeName).Unwrap();
                        // TODO: register this obj with the remoting framework here as 
a singleton
                        return RemotingServices.Marshal(obj,objectUri);

}

TIA,
John

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to