Where to put remote activator in the client?
- From: "Toble Rone" <toble5@xxxxxxxxxxxx>
- Date: Wed, 6 Apr 2005 20:37:33 -0300
I'm developing a Remoting project and after reading and testing a LOT with
all the posibilities, I'm getting trouble with an "architectural" topic.
I have a console app hosting a remotable object quite well, and during
testing, I can conect with simple "client" apps with all the necesary code
related to remoting running inside the "form_load" event.
Now, in my project, when the app starts... i need to stablish a connection
to the remote object (i mean, create an instanse of the remote object) that
need to be called in a lot of places, including several forms and other
classes.
Where is the best place to put the activation code in the client?.
I'm thinking in something like this:
A global.cs class that have the static main() entry point... that fires the
application itself. With the remote object as a public static one:
-----------------------
using System;
using System.Windows.Forms;
namespace RemotingServer_WinTest
{
public class Global
{
public static RemoteObject remObject;
public Global()
{
}
[STAThread]
static void Main()
{
TcpClientChannel ch = new TcpClientChannel();
ChannelServices.RegisterChannel(ch);
remObject = (RemoteObject) Activator.GetObject (typeof
(RemoteObject), "tcp://localhost:4910/RemoteObject",
WellKnownObjectMode.Singleton);
Form1 mainForm = new Form1();
Application.Run(mainForm);
}
}
}
---------------------------------------------------------
So, in every place where I need to make a remote call.... i simply use:
Global.remObject.AnyMethod()
So, here are my questions:
a) Is this a correct way of doing this?
b) Is it safe?
c) If it's no the correct way.... how exactly can I acomplish this?
Thanks in advance
Tob.
.
- Follow-Ups:
- Re: Where to put remote activator in the client?
- From: GuidoD
- Re: Where to put remote activator in the client?
- Prev by Date: StrongNameIdentityPermissionAttribute and remoting problems
- Next by Date: DCOM interop with explicit credential
- Previous by thread: StrongNameIdentityPermissionAttribute and remoting problems
- Next by thread: Re: Where to put remote activator in the client?
- Index(es):
Relevant Pages
|