Re: Where to put remote activator in the client?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
>
>


.



Relevant Pages

  • Where to put remote activator in the client?
    ... I'm developing a Remoting project and after reading and testing a LOT with ... Now, in my project, when the app starts... ... to the remote object that ... TcpClientChannel ch = new TcpClientChannel; ...
    (microsoft.public.dotnet.framework.remoting)
  • Remote event subscription not working.
    ... I'm trying to implement a remote object and ... I'm using an event wrapper as suggested in Ingo ... but code for the remoting client. ... TcpClientChannel tcpChannel = new TcpClientChannel; ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: ASP.net client using Local .dll instead of remote
    ... When the client is an ASP.NET app, ... seperate config file. ... > I have a relatively simple remote object hosted in IIS on a separate ... > but the web app always runs the local copy of the .dll file and never ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Remote object sending from server to client to local client
    ... remote object and has a single TCP channel open. ... I also have a client (clt) that retrieves that object from a TCP ... I tried returning the srv remote object from a method call on clt ... app invokes a method on clt and this method returns the srv ...
    (microsoft.public.dotnet.framework.remoting)
  • ASP.NET: 401 (Unauthorized) error
    ... On localhost I have an ASP.NET app hosting a remote object. ... test authenticating, then authorizing/denying users based on their Windows ...
    (microsoft.public.dotnet.framework.aspnet.security)