Home All Groups Group Topic Archive Search About

Activator.GetObject Method (Type, String)

Author
16 Jul 2006 6:52 PM
newscorrespondent
This method does not fail if the site is not running! Is there a way to
check the proxy for failure?


Thanks
Tom

Author
16 Jul 2006 10:43 PM
Nicholas Paldino [.NET/C# MVP]
Tom,

    What do you mean if the site is not running?  Can you post an example?


--
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard.caspershouse.com

<newscorrespond***@charter.net> wrote in message
Show quote
news:%Wvug.401$OM.68@fe07.lga...
>
> This method does not fail if the site is not running! Is there a way to
> check the proxy for failure?
>
>
> Thanks
> Tom
Author
16 Jul 2006 11:15 PM
newscorrespondent
Yes

//    start the process to talk to
Process TrackersProcess = Process.Start(@"some good thing to starg",
TrackerBuilder.ToString());   

//  set me up to send
ClientChannel = new IpcClientChannel();
ChannelServices.RegisterChannel(ClientChannel, true);               
WellKnownClientTypeEntry remoteType = new
WellKnownClientTypeEntry(typeof(MTGClassLibrary.MTGTracksMessage),
TrackerURL);
RemotingConfiguration.RegisterWellKnownClientType(remoteType);

// here is the example

MessageTracker = (MTGTracksMessage) Activator.GetObject
(typeof(MTGClassLibrary.MTGTracksMessage), TrackerURL);   

If I comment out the start process the GetObject still works.
Author
16 Jul 2006 11:24 PM
Goran Sliskovic
newscorrespond***@charter.net wrote:
Show quote
> Yes
>
> //    start the process to talk to
> Process TrackersProcess = Process.Start(@"some good thing to starg",
> TrackerBuilder.ToString());   
>
> //  set me up to send
> ClientChannel = new IpcClientChannel();
> ChannelServices.RegisterChannel(ClientChannel, true);               
> WellKnownClientTypeEntry remoteType = new
> WellKnownClientTypeEntry(typeof(MTGClassLibrary.MTGTracksMessage),
> TrackerURL);
> RemotingConfiguration.RegisterWellKnownClientType(remoteType);
>            
> // here is the example
>
> MessageTracker = (MTGTracksMessage) Activator.GetObject
> (typeof(MTGClassLibrary.MTGTracksMessage), TrackerURL);   
>
> If I comment out the start process the GetObject still works.

This is by design. Activator.GetObject
  does not actually connect, it only returns proxy object. Connection is
established at the moment first remote call is made ("lazy connect").
That was bad desing decision IMHO, but it is as it is. You could
implement dummy method ("Ping()") on your remote object on which you can
check (and force) connection.

Regards,
Goran
Author
17 Jul 2006 12:34 PM
newscorrespondent
That was the way I read it but I often miss the obvious.

Thanks
Author
16 Jul 2006 11:08 PM
Tom Spink
newscorrespond***@charter.net wrote:

>
> This method does not fail if the site is not running! Is there a way to
> check the proxy for failure?
>
>
> Thanks
> Tom

Hi Tom,

Are you talking about remoting?  Can you provide a code sample?

--
Hope this helps,
Tom Spink

Google first, ask later.

AddThis Social Bookmark Button