n its current release, the .NET Compact Framework does not encourage the development of applications with a distributed object model because it doesn't support .NET remoting. That leaves only a single interoperability option: Web services. I'm not by any means attempting to establish a case in favor of or against the use of Web services; however, Web services may not be appropriate for some types of mobile applications. Fortunately, you can create your own remoting solution. The example chat application in this article will show you how to do that.
You will need two third-party products to compile and test the example application: MiddSol's MinCor.NET (an object request broker for the Compact Framework written in C#) and MiddCor (the counterpart that runs in a standard .NET environment). If you want to follow along, I recommend that you first download and install the sample Visual Studio solution code
, and download the MiddCor and MinCor libraries from the Middsol Web site
as well. When you load the solution into Visual Studio for the first time, you will need to fix the references to the MinCor and MiddCor libraries. To do that, right-click on any broken entries in the References sections of the Solution Explorer and select 'Remove'. Then right-click on 'References' and select 'Add Reference'. Make sure that there is a reference to MinCorSmartPhone.dll in the client project (usually in C:\Program Files\Middsol\MinCor\bin
) and one to MiddCor.dll in the server project (usually found in C:\Program Files\Middsol\MiddCor\bin
If you choose not to install the solution files, the links to code listings found throughout the text should give you a good idea of the techniques used; however, the listings do not contain all the code required to run the sample.
|What You Need
|Microsoft Visual Studio .NET 2003, MiddSol MinCor.NET Evaluation, MiddSol MiddCor.NET Evaluation, Microsoft Smartphone 2003 SDK, and (optionally) Microsoft ActiveSync.
|Figure 1. A Distributed Application: A Smartphone with a .NET Compact Framework client connects to a .NET server.|
A chat application is good for studying distributed objects because the business logic is relatively simple, yet the application still requires some non-trivial features at the communication level. The example application consists of a chat subscriber (a Smartphone 2003 device) and a chat host component (a .NET host application), connecting through the Internet (see Figure 1
Chat subscribers specify a UserID and their favorite hobby. Given the chat host's IP address, subscribers can connect to that host and send messages that all subscribers will see on their displays.