Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / December 2004

Tip: Looking for answers? Try searching our database.

Can I create a remote object without a DLL on the client?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Garann Means - 17 Dec 2004 19:05 GMT
Either I've completely misunderstood Remoting, or misunderstood what it's
useful for. In all the examples I've seen of accessing an object on a
remoting server, you have to specify the type of the object. How can I do
that without a copy of the object on my client machine? And if I do have to
have the object on the client, why wouldn't I just instantiate it?

I've tried to Google the answer, but I don't even know what to search for...
Any help would be very greatly appreciated.

Thanks,
Garann
Ken Kolda - 17 Dec 2004 21:40 GMT
Remoting is not a means of deploying objects/assemblies or of loading
assemblies without having the code locally. It's for creating instances of
objects that are held in a process space other than that of the client. It
doesn't sound like that's what you're trying to do given your comment "why
wouldn't I just instantiate it".

If you want a client app that downloads assemblies dynamically from a remote
location, look into "smart client applications" and "no-touch" deployment.
Here's an article to get you started:

http://msdn.microsoft.com/netframework/programming/winforms/smartclient.aspx

Ken

> Either I've completely misunderstood Remoting, or misunderstood what it's
> useful for. In all the examples I've seen of accessing an object on a
[quoted text clipped - 7 lines]
> Thanks,
> Garann
Garann Means - 17 Dec 2004 22:04 GMT
Hi Ken,

Deploying assemblies is the last thing I want to do. Deploying business
logic on the client machines is something we're trying to avoid in general.
I'd like the objects to remain on the server and have the client access their
methods and properties as needed. However, I'd occasionally need a
Client-Actived Object to do this, since I'll need to maintain the state of
the object, but not share that state across every instance of the object.

My question about why you wouldn't just instantiate the object was related
specifically the Client-Actived Objects. In the examples I've tried, it
appears that they run on my client machine, not in the server's process
space. So I don't see what they offer. Or maybe my tests have been off...

At any rate, I'd still like to know whether there's a way of getting the
Type of the service being offered from the server without having to have the
code for the object on the client.

Thanks,
Garann

> Remoting is not a means of deploying objects/assemblies or of loading
> assemblies without having the code locally. It's for creating instances of
[quoted text clipped - 23 lines]
> > Thanks,
> > Garann
todd.mancini@gmail.com - 17 Dec 2004 22:36 GMT
Did you look into deploying interfaces to the client?

For example, in a class library, put:

public interface IServer
{
void DoSomething();
}

Now you can deploy this class library to the clients.  It does not have
any business logic, but does let the clients know the 'contract' to the
server.

The server would be implemented as:

public class MyServer : IServer, MarshalByRefObject
{
void DoSomething()
{
// Business logic goes here
}
}

The 'magic' here is that the clients only need to reference a TYPE, and
an interface is a type just as much as a class is a type.  The clients
can call methods on the interface; remoting will proxy the calls over
to the actual implementation running in the server.
Garann Means - 17 Dec 2004 22:51 GMT
Hi Todd,

I have seen some information (albeit conflicting information) suggesting
that Interfaces would be the way to go. It's still not a solution I'm really
happy with, since I really don't want anything but code for the UI on the
client. Is that the only way?

I guess I'm hoping for something similar to a web service, where I can make
a reference to the remote type and just have .NET accept that I've know what
I'm doing with regard to calling its methods until runtime.

Thanks,
Garann

> Did you look into deploying interfaces to the client?
>
[quoted text clipped - 23 lines]
> can call methods on the interface; remoting will proxy the calls over
> to the actual implementation running in the server.
Ken Kolda - 17 Dec 2004 23:34 GMT
But a web service also requires the client to know the interface for the
service's methods, right? The client has to know what parameters are
expected, what their names are and/or in what order they occur. No matter
what solution you pick, the client must know this type of info to interact
with the server. So, for remoting, the requirement is that the client have
interface definitions. There's no implementation here, just method
signatures so the client know how to call the server. I'm not sure how you
would get away with anything less.

Ken

> Hi Todd,
>
[quoted text clipped - 37 lines]
> > can call methods on the interface; remoting will proxy the calls over
> > to the actual implementation running in the server.
Garann Means - 17 Dec 2004 23:55 GMT
Well, I may be doing something wrong, but when I've worked with web services
the Web Reference has allowed me to see what's in the service without needing
to have a copy of the web service's object on the client. I need the types
the service's methods will return, but these are generally string or
arraylist or something common, so I haven't had any trouble.

I guess we'll just use remoting for the data that doesn't need to maintain
it's state.

Thanks for all your help,
Garann

> But a web service also requires the client to know the interface for the
> service's methods, right? The client has to know what parameters are
[quoted text clipped - 51 lines]
> > > can call methods on the interface; remoting will proxy the calls over
> > > to the actual implementation running in the server.
Ken Kolda - 18 Dec 2004 00:55 GMT
When you add a WebReference, VS.NET creates a wrapper class for you which
contains the interface for the web service's methods. That's then compiled
into the client. So it's really no different -- you have to have the
interface definition. The same for remoting. You don't have to have the
actual object definition on the client -- just an interface. For example,
you could create an assembly name RemotingInterfaces.dll with an interface
defined as follows:

interface MyRemoteObjectInterface
{
   string DoSomething(int a);
}

Then, on your server, you could create an assembly names ServerObjects.dll
with a class that implements this interface, e.g.

class MyRemoteObject : MarshalByRefObject, MyRemoteObjectInterface
{
   string DoSomething(int a) { return a.ToString(); }
}

The ServerObject.dll would lives on the server only -- the client does not
have access to it and thus has no access to the implementation of the class.
The client only has requires access to the RemotingInterfaces assembly. For
more info on this form of remoting and how to set it up, see:

http://www.genuinechannels.com/Content.aspx?id=28&type=1

Ken

> Well, I may be doing something wrong, but when I've worked with web services
> the Web Reference has allowed me to see what's in the service without needing
[quoted text clipped - 63 lines]
> > > > can call methods on the interface; remoting will proxy the calls over
> > > > to the actual implementation running in the server.
todd.mancini@gmail.com - 18 Dec 2004 17:34 GMT
Ken beat me to the answer!  But I'll give my own $0.02, anyway.

One of the 'dangers' of using an IDE like Visual Studio.NET is that you
are missing a lot of a mechanics because the wizards are doing a lot of
the work for you.  Certainly, this makes life much easier from a
development standpoint, but time-and-time again I've seen it lead to
the kind of confusion which you are facing right now.

There is no magic -- the client needs to know SOMETHING about the
server if it wants to interact with it.  You could devise a completely
late-bound remoting mechanism, so that absolutely nothing exists on the
client, but the client code would still need to know "I need to call a
method named 'Foo' and pass in two parameters."  Do you really want to
hard-code that kind of logic in the client, with no automatic means for
verifying that the client and the server are no longer in sync?

Look at it another way -- why not prototype some client code that would
look the way that you want.  Next, determine how you could possibly
achieve that goal.

If you want to write statically-bound C# or VB code like this:

theServer.DoSomething(5)

then it is clear that the client code needs to have infomation about
the server, because that's the nature of these languages.  There is no
way to compile that code if the code does not know about the type of
'theServer".

If, instead, you want to do something late-bound such as:

theServer.ExecuteMethod("DoSomething", 5)

then you can get away with the client not knowing anything about the
DoSomething method on the server.  You still need some generic remoting
type for 'theServer', so that the ExecuteMethod is known to the client,
but you could concievably reuse this code for all of your remoted
objects.

Of course, if the server modifies the DoSomething method to take
exactly two arguments, your client code will break and you won't know
this at compile time; you'll have to hope you catch it during
regression testing.

So, really, I encourage you to write some client code that looks the
way you want, and then decide if it's possible, given the constraints
of the language you are using.  [There are completely late-bound
languages out there, so maybe they'd be a better fit for your
development style.]
Garann Means - 20 Dec 2004 16:59 GMT
Thank you both for elaborating. It had never occured to me that Visual Studio
was doing something behind the scenes when I added references to web
services. I guess I should have realized when I was suddendly able to see the
web service's methods.

Thanks again for all your help!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.