.NETGURU
How returning a remote object created in the server
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.remoting.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Maurizio Poletto (VIP)
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
Reply to this message...
 
    
Maurizio Poletto (VIP)
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:

[Original message clipped]

Reply to this message...
 
    
Ken Kolda
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" <Click here to reveal e-mail address> wrote in
message news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Maurizio Poletto (VIP)
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:

[Original message clipped]

Reply to this message...
 
    
Sam Santiago
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/cpconBasicRemotingTaskList.asp

Thanks,

Sam

--
_______________________________
Sam Santiago
Click here to reveal e-mail address
http://www.SoftiTechture.com
_______________________________
"Maurizio Poletto" <Click here to reveal e-mail address> wrote in
message news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Sam Santiago
You want each client to have a "session" object which implies you want to
use a CAO - Client Activated Object. All you have to do is derive your
Session object from MarshalByRefObject and have your server singleton object
return it. We had a discussion on this scenario several times of the
passed few weeks so search for factory pattern in this group or I also put
some of the discussion on my site:
http://www.SoftiTechture.com/discussions.

Thanks,

Sam

--
_______________________________
Sam Santiago
Click here to reveal e-mail address
http://www.SoftiTechture.com
_______________________________
"Maurizio Poletto" <Maurizio Click here to reveal e-mail address> wrote in
message news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.MarshalByRefObject
System.Runtime.Remoting.ObjRef
System.Runtime.Remoting.RemotingServices




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification