.NETGURU
SingleCall calling SingleTon object
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.remoting.

Post a new message to this list...

Lord2702
Mon. Sep. 13, 2004 1:20 PM PT

Suppose, I have a server, which hosts two ExamGuruO's, one is SingleCall
(ExamGuruO_One) and another is SingleTon (ExamGuruO_Two). Both hosts on one server,
Now, client will call a function from ExamGuruO_One, which further calls a
function in ExamGuruO_Two. Is it possible to place this call. If possible, then
how do I activate the ExamGuruO_Two object, on ExamGuruO_One object side. Because Both
these objects are on one AppDomain, whereas Client is on separate domain.

Thanks.

Reply to this message...
 
    
Ken Kolda
Assuming it's your single-call object accessing your singleton, you can do
this two ways:

1) Marshal your singleton manually instead of using the
RemotingConfiguration.RegisterWellKnownServerObject(). This will allow you
to create a static instance of your remoted class which is accessible both
by remote objects and objects in the same AppDomain. For example:

class MySingletonObject : MarshalByRefObject
{
public static MySingletonObject RemotedObject = new MySingletonObject();
}

class MyServer
{
public static void Main()
{
// Marshal object manually
RemotingServices.Marshal(MySingletoneObject.RemotedObject,
"Singleton.rem");
}
}

class MySingleCallObject : MarshalbyRefObject
{
public void SomMethod()
{
MySingletonObject.RemotedObject.SomeOtherMethod();
}
}

2) You can actually make your server a client of itself. In your SingleCall
object's methods, you would use Activator.GetObject() to fetch a reference
to the Singleton. This will be slower because you're actually going out thru
remoting and back in with each method call, but it requires less work. Plus,
if the object you're calling is SingleCall instead of Singleton, this is the
only way to do it (beside various techniques of wrapping the single-call
object).

Hope that helps -
Ken

"Lord2702" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Lord2702
Yes that helps a lot, I actually thought of making SingleTon ExamGuruO as
Singleton, but then stop, at the point that hey, as already this object is A
Singleton, but then in your design, it makes me simple to access the static
instance of SingleTon object. Thanks.

"Ken Kolda" <Click here to reveal e-mail address> wrote in message
news:%23%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Activator
System.AppDomain
System.MarshalByRefObject
System.Runtime.Remoting.RemotingConfiguration
System.Runtime.Remoting.RemotingServices




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification