[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Talking to the server from the hosting app.

Phil Jones

8/16/2004 2:33:00 AM

I have a Remoting server assembly being hosted within a windows Form.

There is an Singleton object published by the server. The object can be
retrieved via an shared "Instance" field that retrieves an instance of
itself (as per the .NET Singleton pattern).

Here's the weird thing I'm finding. If I grab the Singleton instance of the
object from the client - I can work with that, and it is really a single
instance to all interaction on the client(s).

But if I grab an instance via Instance property from the hosting Window's
Forms app - it return a different object (a new instance).

I don't get it! Is the win forms calling in from a different app-domain.
This doesn't quite stack because I can retrieve events from the assembly
(within the WinForms app) that are instigated by calls from clients.

Does this sound weird? From the winforms app - shouldn't I be talking
directly to the same app-doimain that the remote clients are talking to??

Thanks everyone.
==
Phil






4 Answers

Sam Santiago

8/16/2004 3:28:00 AM

0

Can you post some stub code to see what's happening? The remoting Singleton
is not truly a singleton in the classic sense unless you override the
lifetime and have it live forever. Otherwise, you always have a single
object available to client, but depending on the lease lifetime (default it
5 minutes if you don't override) it may get destroyed and recreated. Do you
programmatically instantiate the object and then make it available via the
RemotingServices.Marshal method? For example,

RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri")

Thanks,

Sam
--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Phil Jones" <phil_newsgroup@hotmail.com> wrote in message
news:uRS%23sfzgEHA.3348@TK2MSFTNGP12.phx.gbl...
> I have a Remoting server assembly being hosted within a windows Form.
>
> There is an Singleton object published by the server. The object can be
> retrieved via an shared "Instance" field that retrieves an instance of
> itself (as per the .NET Singleton pattern).
>
> Here's the weird thing I'm finding. If I grab the Singleton instance of
the
> object from the client - I can work with that, and it is really a single
> instance to all interaction on the client(s).
>
> But if I grab an instance via Instance property from the hosting Window's
> Forms app - it return a different object (a new instance).
>
> I don't get it! Is the win forms calling in from a different app-domain.
> This doesn't quite stack because I can retrieve events from the assembly
> (within the WinForms app) that are instigated by calls from clients.
>
> Does this sound weird? From the winforms app - shouldn't I be talking
> directly to the same app-doimain that the remote clients are talking to??
>
> Thanks everyone.
> ==
> Phil
>
>
>
>
>
>


Phil Jones

8/16/2004 5:35:00 AM

0

Hey Sam,

I'll start stripping out some stub code.

What I'm doing is publishing a "Factory" type object using the
[RemotingConfiguration.RegisterWellKnownServiceType] method. I'm not sure
what the difference between that and [RemotingServices.Marshal] is - but
upon trialling them both they "appear" to produce the same results.

That factory then retrieves the singlton objects I'm working with by
returning their shared "Instance" singlton fields.

The reason I'm doing this is that it creates a single point of access to the
server (which I'm figuring will be useful from a housekeeping perspective).
I'm not sure if it has any bearing of this issue I'm experienceing however.

Thanks for your interest and help Sam. Really appreciated.

===
Phil
(Auckland | Aotearoa)


Sam Santiago

8/16/2004 6:08:00 AM

0

You might want to check out some sample code I posted here:
http://www.softitechture.com/d... regarding factory objects. Also,
there was a discussion regarding factories in this newsgroup a couple of
weeks ago that might be useful:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=%23ms6%24x%23dEHA.720%40TK2MSFTNGP11.phx.gbl&rnum=1&prev=/groups%3Fas_q%3Dcao%2520sao%2520factory%26safe%3Dimages%26ie%3DUTF-8%26as...*microsoft*%26lr%3D%26hl%3Den

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=eACbPVXeEHA.332%40TK2MSFTNGP09.phx.gbl&rnum=10&prev=/groups%3Fas_q%3Dcao%2520sao%2520factory%26safe%3Dimages%26ie%3DUTF-8%26as...*microsoft*%26lr%3D%26hl%3Den

Thanks,

Sam
--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Phil Jones" <phil_newsgroup@hotmail.com> wrote in message
news:e9N$lF1gEHA.712@TK2MSFTNGP09.phx.gbl...
> Hey Sam,
>
> I'll start stripping out some stub code.
>
> What I'm doing is publishing a "Factory" type object using the
> [RemotingConfiguration.RegisterWellKnownServiceType] method. I'm not sure
> what the difference between that and [RemotingServices.Marshal] is - but
> upon trialling them both they "appear" to produce the same results.
>
> That factory then retrieves the singlton objects I'm working with by
> returning their shared "Instance" singlton fields.
>
> The reason I'm doing this is that it creates a single point of access to
the
> server (which I'm figuring will be useful from a housekeeping
perspective).
> I'm not sure if it has any bearing of this issue I'm experienceing
however.
>
> Thanks for your interest and help Sam. Really appreciated.
>
> ===
> Phil
> (Auckland | Aotearoa)
>
>


Phil Jones

8/17/2004 1:59:00 AM

0

Cheers - I'll check them out. Appreciate the pointer.