Table of Contents
“Smart Clients are easily deployed and managed client applications that provide an adaptive, responsive and rich interactive experience by leveraging local resources and intelligently connecting to distributed data sources”. (MSDN)
- Use peer-to-peer technology.
- Access local APIs.
- Harness the full power of available resources efficiently and safely.
- Consume web services like web applications.
- They support work offline – Smart Clients can work with data even when they are not connected to the Internet (which distinguishes them from browser-based applications, which do not work when the device is not connected to the Internet).
- Smart Client applications have the ability to be deployed and updated in real time over the network from a centralized server.
- Smart Client applications can run on almost any device that has Internet connectivity, including desktops, workstations, notebooks, tablet PCs, PDAs, and mobile phones.
The Smart Client architecture is not ideal for every scenario. In situations such as e-commerce, where user platforms are unknown or diverse, the browser-based model continues to represent the most practical approach. However, in the context of a corporate computing environment, where clients are known to be running the Windows operating system, the Smart Client model is the architecture of choice, combining the power and flexibility of rich client applications with the stability and ease of deployment associated with browser-based applications.
Smart Clients vary greatly in design and implementation, both in application requirements and in the number of scenarios and environments in which they can be used. Smart Clients therefore can take many different forms and styles. These forms can be divided into three broad categories according to the platform that the Smart Client application is targeting:
- Windows Smart Client applications
- Office Smart Client applications
- Mobile Smart Client applications
In this article we’ll be concentrating only on Windows Smart Client applications.
This article demonstrates:
- Steps that need to be followed to integrate a Smart Client application with existing web based applications.
- How to pass parameters to Smart Client applications through URL.
- How to detect and install the .NET Framework on client machines automatically.
- Server based installation of “client” for Smart Client applications.
As before, Smart Client applications can be delivered by CD, DVD, floppy disk, or via an application deployment infrastructure such as Microsoft Systems Management Server. The .NET Framework introduces yet another option: no-touch deployment, deploying the application from a remote Web server using the Hypertext Transfer Protocol (HTTP).
Smart Clients were introduced in 2002, along with the .NET Framework 1.1 with Visual Studio 2003 release. Building and deploying Smart Client applications takes a giant step forward with Visual Studio 2005 and the .NET Framework 2.0.
In this article, the steps and screenshots given are of Smart Client applications developed using the .NET framework 2 (Beta) with Visual Studio 2005 Beta version.
A simple Windows Application project is developed for demonstration on a Smart Client. In this application, we’ll see:
- How to launch an EXE application through a URL.
- How to access a URL and parameters.
Here, in the sample demo, we’ll pass the parameter named color_name through URL (web application). Then in the client application, which is nothing but a Windows EXE, we access this value and displays the item (here, the used rectangle) with the color value mentioned.
Below are the steps involved in developing this Smart Client application:
The following code snippet is used to access the URL in the form:
using System.Deployment.Application;
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
String str = ad.ActivationUri.ToString();
Split the URL and retreive the value passed in querystring.
The .NET framework is a prerequisite for all the Smart Client applications. This can be auto downloaded when a Smart Client application is called the first time. Following are the various ways to set the auto download feature:
- Click on Project Properties and Publish tab.
- Click on Prerequisite button.
- Make sure to select the check box for “Create Setup Program to install prerequisite components”.
- Below are the options for install location for prerequisites:
- Download prerequisites from component vendor's web site: This option requires the user to be connected to the Internet. .NET framework will be downloaded from Microsoft website.
- Download prerequisites from the same location as my application: If this option is selected then the .NET Framework setup is searched from the application development machine. (This is the option set for the sample application.)
- Download prerequisites from the following location: For this option you should know the IP address of the deployment machine in advance. You can specify the virtual path where the Setup.exe will be present.
- Build the application.
- Select Project Properties.
- Go to Publish tab.
- Click on Publish Now button.
After publishing the application successfully, .NET will create a publish directory under the application folder. Make this directory as a virtual directory.
These steps will now explain to you how to launch the application from a URL. As it’s mentioned earlier, we are passing a parameter through the URL, which we need, to access in the Windows application. We created some dummy test pages, which we will use to pass the parameter and to launch the application.
- Test page, contains two HTML controls, a combo box which contains the list of colors, and a Submit button.
- User can select the color from the combo box that needs to be displayed in the application or need to be passed in the query string.
- On clicking the Submit button, the page calls the
SmartDemo.application
from the publish folder of the project, by passing the selected value in the combo box.
- This web page auto detects the presence of the .NET framework on the client machine.
- If the .NET Framework is not present then the JavaScript redirects the user to the page (specified in the property) which will provide the link to install the .NET framework (Install.htm).
- If the framework is present then the application will be open up automatically.
Below is the JavaScript to detect the presence of the .NET Framework on the client machine. (This is the same method which publish.htm uses to detect the .NET framework.)
<SCRIPT Language="JavaScript">
<!--
runtimeVersion = "2.0.0";
directLink = "Bomedit.application";
function checkComponent()
{
if (HasRuntimeVersion(runtimeVersion))
{
InstallButton.href="http://<DevelopmentMachineName>" +
"/<VirtualDirectory>/<ApplicatonName>.application";
}
else{
window.open("http://<DeploymentMachineName>/VirtualDirectory /Test.htm");
}
}
function HasRuntimeVersion(v)
{
var va = GetVersion(v);
var i;
var a = navigator.userAgent.match(/\.NET CLR [0-9.]+/g);
if (a != null)
for (i = 0; i < a.length; ++i)
if (CompareVersions(va, GetVersion(a[i])) <= 0)
return true;
return false;
}
function GetVersion(v)
{
var a = v.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i);
return a.slice(1);
}
function CompareVersions(v1, v2)
{
for (i = 0; i < v1.length; ++i)
{
var n1 = new Number(v1[i]);
var n2 = new Number(v2[i]);
if (n1 < n2)
return -1;
if (n1 > n2)
return 1;
}
return 0;
}
-->
</SCRIPT>
- Create a Web Setup project
- Add the contents of the publish folder to the Web Application folder.
- Build the setup project.
- Run the setup project on the deployment machine
- Edit test.html page and give the path of the Smart Demo application in the deployment folder as the link for the Smart Client application.
Below are some of the errors that we faced during development:
This error comes if you try to access the URL using ApplicationDeployment.CurrentDeployment.ActivationUri
by running the project from the IDE. This property can be used only after deploying the application.
<Filename>. Deploy cannot be found.
This is a post deployment error. It occurs if the xyz.deploy file for any of the dependent files is missing in the deployment folder. Check your setup project. Include the xyz.deploy file which is mentioned in the error, and re-deploy the project.
- Smart Client applications are easy to integrate with existing web applications (independent of the architecture of the web application - .NET/J2EE).
- Visual studio 2005 provides ready features to access the URL from which the application was run.
- It does not require any special settings in IIS (these settings are required if you have developed the application in Visual Studio 2003).
- Smart Client applications can be configured to automatically detect the presence of the .NET framework on the client machine. If the Framework is not installed then it can be downloaded automatically and run on the client machine.