[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

Copy a remote object localy

Sylvain Ross

8/4/2004 12:02:00 AM

Hi,

Here is my story :

I got a client and a server. The client sends what I call a "Bag" (which
is an object inherited from MarshalByRefObj) with a SubmitBag(b as Bag)
call to my server object.
On my server now, when I got this bag with my SubmitBag sub, I got in
fact a proxy.
The problem is that I would like to have a real object on my server from
this proxy. This bag inmplements Cloneable. But when doing this on the
server :

dim myHomeBag as Bag = myReceivedBag.Clone()

myHomeBag is then a proxy ! But after all this is normal since the clone
object is created remotely then returned...

I'm using MarshalByRef because this object is then accessed remotely by
another server. I can't relie on the client to host the object (if it
crashes than I'm lost), that's why I just want to create it on the
client and then to host it on the central server, to be accessed by the
other servers, remotely.


Of course I can create a blank local instance and affect every members
from the proxy but I don't want to do that since I got a big number of
members.


If anyone has some ideas...

Thx in advance.


Sylvain
3 Answers

Sylvain Ross

8/4/2004 12:12:00 AM

0

A solution should be to create the object on the client, and send the
whole object on the SubmitBag() call instead of just sending a proxy.

I think this is called Serialization and this is made automaticly when
submiting an object which doesnt inherits from MarshalByRef.

Is there a way to kind of force this serialization?


Thx in advance


Sylvain Ross

Sylvain Ross wrote:
> Hi,
>
> Here is my story :
>
> I got a client and a server. The client sends what I call a "Bag" (which
> is an object inherited from MarshalByRefObj) with a SubmitBag(b as Bag)
> call to my server object.
> On my server now, when I got this bag with my SubmitBag sub, I got in
> fact a proxy.
> The problem is that I would like to have a real object on my server from
> this proxy. This bag inmplements Cloneable. But when doing this on the
> server :
>
> dim myHomeBag as Bag = myReceivedBag.Clone()
>
> myHomeBag is then a proxy ! But after all this is normal since the clone
> object is created remotely then returned...
>
> I'm using MarshalByRef because this object is then accessed remotely by
> another server. I can't relie on the client to host the object (if it
> crashes than I'm lost), that's why I just want to create it on the
> client and then to host it on the central server, to be accessed by the
> other servers, remotely.
>
>
> Of course I can create a blank local instance and affect every members
> from the proxy but I don't want to do that since I got a big number of
> members.
>
>
> If anyone has some ideas...
>
> Thx in advance.
>
>
> Sylvain

Sam Santiago

8/4/2004 6:38:00 AM

0

Instead of making Bag inherit from MarshalByRefObject you could make Bag a
simple marshal-by-value object by using the Serializable attribute:

<Serializable()> Public Class Bag ...

Then on the server side define another wrapper class that inherits from
MarshalByRefObject that has a member of type Bag that can be remoted. So
your SubmitBag function would accept a Bag as parameter that is
marshaled-by-value so it will not be a proxy and then instantiates the
wrapper object and sets a Bag member to the parameter passed in.

Thanks,

Sam


--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Sylvain Ross" <sross@free.fr> wrote in message
news:411029df$0$21745$626a14ce@news.free.fr...
> A solution should be to create the object on the client, and send the
> whole object on the SubmitBag() call instead of just sending a proxy.
>
> I think this is called Serialization and this is made automaticly when
> submiting an object which doesnt inherits from MarshalByRef.
>
> Is there a way to kind of force this serialization?
>
>
> Thx in advance
>
>
> Sylvain Ross
>
> Sylvain Ross wrote:
> > Hi,
> >
> > Here is my story :
> >
> > I got a client and a server. The client sends what I call a "Bag" (which
> > is an object inherited from MarshalByRefObj) with a SubmitBag(b as Bag)
> > call to my server object.
> > On my server now, when I got this bag with my SubmitBag sub, I got in
> > fact a proxy.
> > The problem is that I would like to have a real object on my server from
> > this proxy. This bag inmplements Cloneable. But when doing this on the
> > server :
> >
> > dim myHomeBag as Bag = myReceivedBag.Clone()
> >
> > myHomeBag is then a proxy ! But after all this is normal since the clone
> > object is created remotely then returned...
> >
> > I'm using MarshalByRef because this object is then accessed remotely by
> > another server. I can't relie on the client to host the object (if it
> > crashes than I'm lost), that's why I just want to create it on the
> > client and then to host it on the central server, to be accessed by the
> > other servers, remotely.
> >
> >
> > Of course I can create a blank local instance and affect every members
> > from the proxy but I don't want to do that since I got a big number of
> > members.
> >
> >
> > If anyone has some ideas...
> >
> > Thx in advance.
> >
> >
> > Sylvain


Sunny

8/4/2004 3:11:00 PM

0

Hi,

In article <411029df$0$21745$626a14ce@news.free.fr>, sross@free.fr
says...
> A solution should be to create the object on the client, and send the
> whole object on the SubmitBag() call instead of just sending a proxy.
>
> I think this is called Serialization and this is made automaticly when
> submiting an object which doesnt inherits from MarshalByRef.
>
> Is there a way to kind of force this serialization?
>
>
> Thx in advance
>
>
> Sylvain Ross
>
> Sylvain Ross wrote:
> > Hi,
> >
> > Here is my story :
> >
> > I got a client and a server. The client sends what I call a "Bag" (which
> > is an object inherited from MarshalByRefObj) with a SubmitBag(b as Bag)
> > call to my server object.
> > On my server now, when I got this bag with my SubmitBag sub, I got in
> > fact a proxy.
> > The problem is that I would like to have a real object on my server from
> > this proxy. This bag inmplements Cloneable. But when doing this on the
> > server :
> >
> > dim myHomeBag as Bag = myReceivedBag.Clone()
> >
> > myHomeBag is then a proxy ! But after all this is normal since the clone
> > object is created remotely then returned...
> >
> > I'm using MarshalByRef because this object is then accessed remotely by
> > another server. I can't relie on the client to host the object (if it
> > crashes than I'm lost), that's why I just want to create it on the
> > client and then to host it on the central server, to be accessed by the
> > other servers, remotely.
> >
> >
> > Of course I can create a blank local instance and affect every members
> > from the proxy but I don't want to do that since I got a big number of
> > members.
> >
> >
> > If anyone has some ideas...
> >
> > Thx in advance.
> >
> >
> > Sylvain
>

As an addition to Sam's answer, there is a possibility (never tried) to
make your Bag object both [Serializable] and MBR.

Then on the client you can manually serialize it to a byte array. Send
this array across the wire and make server deserialize it to a new
object. Then expose that object to all other clients.

As I said, I have never used this, as I do not think this is a good
approach, but I have saved in a file such a serialized object :)

The way Sam recommends is better. Create a wrapper.

Sunny