Sunny
8/4/2004 3:11:00 PM
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