.NETGURU
Interface based serialization
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.remoting.

Post a new message to this list...

Noel Watson
I am attempting to get the example posted on csharphelp to work
http://www.csharphelp.com/archives/archive191.html

The example executes fine, but when checking whether the call

IResume aResume = resService.GetResume();

is passed copied locally to the machine (ByVal), I find that it has
been passed byRef. My check for this is adding a property returning
Environment.MachineName - calling this new property returns the name
of the remote machine.
My understanding is that adding the [Serializable] attribute to the
class Resume would make it serializable. However, it would appear that
adding MarshalByRefObject overrides this and makes it ByRef. Removing
MarshalByRefObject cause the application to fall over as it cannot
find the server assembly - something that can be solved by adding a
reference in Client - obviously this removes the benefits of
Interfaces.

Thanks for reading

Noel
Reply to this message...
 
    
Ken Kolda
You are correct that if the class derives from MarshalByRefObject then it
will be remoted by ref (even if also marked as serializable). You're also
right that if the class is only serializable then the client must have the
full class implementation available to it. Those are the rules, so you need
to figure out how to build your app to work within them.

What I usually do is define a set of data classes (e.g. a InventoryItem or a
Resume object) -- these are purely data classes which are serializable and
are implemented in the same assembly as my remoting interfaces. Essentially,
they are part of the "interface" between my clients and my server.

My ExamGuruO classes are essential business logic classes, e.g. for
getting/saving the data objects, for performing various operations, etc.
These business processes aren't needed on the client (and, really, the
server should control them for security/consistency purposes), so only the
interfaces are exposed to them.

Ken

"Noel Watson" <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...
 
    
Noel Watson
Thanks for the response Ken,

One thing is still puzzling me. Are you not taking away some of the
advantages of interface based remoting (not deploying server code to
the client) by having to place your serializable objects on the
client's machine. I've read the two main books on Remoting (Ingo's and
MSPress) and I don't believe either of them mentioned this
requirement.

Noel
Reply to this message...
 
    
Ken Kolda
I don't think it takes away from it -- in fact, it makes perfect sense to
me. From a technical point of view, it's clear that if the client has its
own local copy of the object then it must also have the implementation code
for that object. Otherwise, when you call a property or method on the
object, how would the client know what to do? For ExamGuruO objects, it doesn't
need the implementation since the call is forwarded to the server -- all it
needs is to know the property arguments and return value. But for
marshal-by-value objects, complete knowledge of the object is required.

As I mentioned before, from a logical point of view I think of serializable
types as part of the client/server interface. They provide a means for
passing data objects back and forth. Business logic classes should generally
by ExamGuru. Because they're part of the "interface", having both client and
server know them is completely reasonable/expected.

Ken

"Noel Watson" <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.Environment
System.MarshalByRefObject




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