One of the major promises of Cairo is distributed computing--the ability to
run components of your computing on other machines on the network. Object
Linking and Embedding (OLE) is the key enabling technology, so it's fascinating
to see early Remote OLE (ROLE) technology starting to appear from Microsoft. It
doesn't have full-blown Cairo functionality, but it demonstrates the underlying
concepts. And it's useful even in today's networked environment.
The Tools
Visual Basic 4 Enterprise Edition (VB4/EE) includes all the components of
ROLE. And other Microsoft tool sets will probably ship with ROLE functionality
in the future. Indeed, the correct place for ROLE is within the operating
system, but that will have to wait until Cairo is completed and ready to roll.
In the VB4/EE package, you get a Remote Automation Connection Manager
(RACM) tool, an Automation Manager application that runs as an icon, and all the
libraries and dynamic link library (DLL) components you need to convert a
machine from OLE to ROLE.
By far, the easiest way to set up a ROLE system is to follow the example
you get with the VB4/EE package and its documentation. This example uses a
simple OLE client application, named Hello/Client, which calls a simple server
application, named Hello/Server. The server application returns a string to the
client application when it's called, and the client displays the textual
contents of that string. As OLE Automation goes, this setup approach is about as
simple as it gets.
Installing and configuring ROLE isn't for the fainthearted. I had several
aborted attempts trying to fly the system manually, and I would be astonished if
anyone was fully successful without following the steps in the "Building
Client Server Applications with Visual Basic" book that comes with VB4/EE.
Suffice it to say, I'm not going to explain how VB4 creates OLE Automation
clients and servers. And you can use whatever OLE client and server engines you
want. But I'll use the Hello examples from the VB4/EE shrink-wrap to show you
what's going on, and how it works under the hood.
The Server Side
The Hello/Server application is a simple VB4 OLE Automation server. It
returns a string that reads, "Hello Microsoft Visual Basic Users" when
an external client calls it by activating the Say Hello() function. In
other words, the client application creates an instance of the Hello/Server
application and fires off its SayHello method; the server then returns the
string to the client application.
Installing the server application is easy. However, you really need to use
the supplied VB4 Setup Kit for the first server application, because the Setup
Kit also copies all the necessary behind-the-scenes files for you. When you have
run the Setup Kit on a server system once, you can just copy new server
applications, as appropriate. As you see in figure 1, the VB4 Setup Kit lets you
determine whether to install the application it builds, as an OLE Automation
shared component or as a standard, stand-alone application.
Once you create the Setup Kit files, run the Setup Kit on the
server--either over the network or via the installation floppy disks created
during the setup process--to install the files there. Then, run the server
application once to load all the Registry settings pertaining to OLE. You could
manually install the type library if you want, but most users find it easier to
just run the application once.
Next, start up the RACM application, and locate the name of the OLE Class
that the server application exposes. (Running the application registers this
name.) From the Client Access tab, set the Allow Remote Creates By Key value,
and ensure that the Allow Remote Activation box is checked, as in figure 2.
Last, run the Automation Manager application. Once launched, it starts
several network-related services and then iconizes itself at the bottom of the
screen.
So the process is to register the application on the server, tell RACM that
the server application can be activated remotely, and then start the Automation
Manager glue application.
The Client Side
On the client machine is a simple application named Hello/Client. It has an
on-form-load event that creates an object instance of the Hello/Server
application. On the Hello/Client main form is a single push-button. Pressing it
calls the SayHello method that the server exposed.
Nothing I've said so far should be surprising, by the way. This is standard
OLE Automation behavior, which is the key to making ROLE work.
Local Activation
To ensure that the client/server system is working correctly, a good idea is
to test it out locally in one computer before trying to make it work across the
network. So run the Hello/Server application on your client system to register
it in the Registry, just as you did on the server system.
Then, start the client application. On the screen, the client and server
windows appear. When you press the button, the message box appears, as in figure 3.
Remote Activation
Close the client and server applications. The server is ready for use, so
the only changes you need to make are on the client side. Go to the RACM
application on the client, locate the HelloProj. HelloClass object, and
make sure that the Server Connection tab is selected.
This selection exposes some settings pertaining to network connections.
Enter the name of the server into the Network Address box, and select the
protocol to use across the network for the connection. Ignore the Authentication
Level combination box for now.
By setting these values, you tell the client where on the network it can
find an instance of the Hello/Server object. The client now has a network
address and a transport protocol, but it still needs to know that the
Hello/Server application is no longer on the local hard disk. The client needs
to find the network version on the network.
This change is easy. Click the right mouse button on the HelloProj entry,
and select Remote instead of Local. The icon indicates the change, which takes
place immediately.
To test the change, fire up the Hello/Client application once more on the
client. (The Hello/Server window doesn't appear on the client's desktop; it
appears on the server's desktop!) Press the button on the client application,
and the message box will appear on the client desktop, filled with the correct
textual information, as in figure 4.