Re: Where to put remote activator in the client?
- From: "GuidoD" <noreply@xxxxxxxx>
- Date: Thu, 7 Apr 2005 14:34:28 +0200
Just create a factory to handle creation issues.
example:
class MyObjFactory
{
static MyObject CreateRemoteInstance()
{
// call activator to create object ..
return obj;
}
}
"Toble Rone" <toble5@xxxxxxxxxxxx> wrote in message
news:%233GxTGwOFHA.3704@xxxxxxxxxxxxxxxxxxxxxxx
> 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: Toble Rone
- Re: Where to put remote activator in the client?
- References:
- Where to put remote activator in the client?
- From: Toble Rone
- Where to put remote activator in the client?
- Prev by Date: Concurrent connection to .Net Remoting server
- Next by Date: Re: Where to put remote activator in the client?
- Previous by thread: Where to put remote activator in the client?
- Next by thread: Re: Where to put remote activator in the client?
- Index(es):
Relevant Pages
|