[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

Re: How returning a remote object created in the server

Ken Kolda

9/7/2004 3:08:00 PM

You've made it more complicated than it needs to be. Here's your server-side
code:

public Session Login(string uiserId, string userPsw)
{
return new Session();
}

On the client side, just use:

Session session = server.Login("ciao", "bella");
session.Initialize();

There's no need to deal with all the ObjRef marshalling directly as that
will be taken care of for you by .NET.

Ken


"Maurizio Poletto" <MaurizioPoletto@discussions.microsoft.com> wrote in
message news:DADC4C96-E6C1-4341-ACBE-23076BE72A57@microsoft.com...
> Thank for your quick reply.
> I have followed any your advise but something seems not to run well!.
> In the server I wrote:
>
> public ObjRef Login(string userId, stringUserPsw)
> {
> Session session = new Session();
> return RemotingServices.Marshal(session);
> }
>
> while, in the client, I wrote:
>
> ObjRef obj = server.Login("ciao","bella");
> Object proxy = RemotingServices.Unmarshal(obj);
> Session session = (Session)RemoteingServices.Connect(typeof(Session),
> "tcp://localhost:8080//Session");
>
> and, after, when I call a method of Session
>
> session.Initialize();
>
> I have an exception i.e. "Requested Service not found"
>
> I understand that this problem was solved successfully, but I spent a lot
of
> time without a happy solution. A bit of help is appreciate!
> Ciao
> Maurizio
>
>
>
>
> "Maurizio Poletto" wrote:
>
> > A singleton object (server) has a method (login) to let to every client
to
> > connect to the server. I should like to return a new object (session)
with
> > new methods.
> >
> > So, in the client, we have
> > Session session = server.login(userId, userPsw);
> >
> > while, in the server, we have
> > Session Login(string Id, string Psw)
> > {
> > ...
> > ...
> > Session session = new Session();
> > return session;
> > }
> >
> > I would appreciate any ideas on how to return an object created in the
server?
> > Regards
> > Maurizio


1 Answer

Sam Santiago

9/8/2004 11:08:00 PM

0

Sounds like you have to ensure your client application has access to the
meta-data of the returned remote object. You either have to deploy your
remote object assembly to your client or define a shared interface.

Check out step#5 of this link:

Basic Remoting Task List
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconBasicRemotingTa...

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Maurizio Poletto" <MaurizioPoletto@discussions.microsoft.com> wrote in
message news:2E1BE8DB-1C2E-444B-8D81-FB5CAFFB6F77@microsoft.com...
> Of course I had already tried in this way, but
> Session session = server.Login("ciao", "bella");
> return an exception: Return argument return an invalid type.
> So that I had tried a workaroud to resolve this problem.
> I don't understand why a so easy code gives me a big problem.
> Thank for any your suggestion.
> Ciao Maurizio
>
>
> "Ken Kolda" wrote:
>
> > You've made it more complicated than it needs to be. Here's your
server-side
> > code:
> >
> > public Session Login(string uiserId, string userPsw)
> > {
> > return new Session();
> > }
> >
> > On the client side, just use:
> >
> > Session session = server.Login("ciao", "bella");
> > session.Initialize();
> >
> > There's no need to deal with all the ObjRef marshalling directly as that
> > will be taken care of for you by .NET.
> >
> > Ken
> >
> >
> > "Maurizio Poletto" <MaurizioPoletto@discussions.microsoft.com> wrote in
> > message news:DADC4C96-E6C1-4341-ACBE-23076BE72A57@microsoft.com...
> > > Thank for your quick reply.
> > > I have followed any your advise but something seems not to run well!.
> > > In the server I wrote:
> > >
> > > public ObjRef Login(string userId, stringUserPsw)
> > > {
> > > Session session = new Session();
> > > return RemotingServices.Marshal(session);
> > > }
> > >
> > > while, in the client, I wrote:
> > >
> > > ObjRef obj = server.Login("ciao","bella");
> > > Object proxy = RemotingServices.Unmarshal(obj);
> > > Session session = (Session)RemoteingServices.Connect(typeof(Session),
> > > "tcp://localhost:8080//Session");
> > >
> > > and, after, when I call a method of Session
> > >
> > > session.Initialize();
> > >
> > > I have an exception i.e. "Requested Service not found"
> > >
> > > I understand that this problem was solved successfully, but I spent a
lot
> > of
> > > time without a happy solution. A bit of help is appreciate!
> > > Ciao
> > > Maurizio
> > >
> > >
> > >
> > >
> > > "Maurizio Poletto" wrote:
> > >
> > > > A singleton object (server) has a method (login) to let to every
client
> > to
> > > > connect to the server. I should like to return a new object
(session)
> > with
> > > > new methods.
> > > >
> > > > So, in the client, we have
> > > > Session session = server.login(userId, userPsw);
> > > >
> > > > while, in the server, we have
> > > > Session Login(string Id, string Psw)
> > > > {
> > > > ...
> > > > ...
> > > > Session session = new Session();
> > > > return session;
> > > > }
> > > >
> > > > I would appreciate any ideas on how to return an object created in
the
> > server?
> > > > Regards
> > > > Maurizio
> >
> >
> >