Click here to Skip to main content
15,860,972 members
Articles / Mobile Apps
Article

Integration of Smart Client applications with existing Web applications

20 Sep 20058 min read 88K   650   58   5
An article on integration of Smart Client applications with existing Web applications.

Table of Contents

Introduction

What is a Smart Client?

“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)

Why Smart Client?

  • 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.

Where and When to Implement Smart Clients

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.

Different types of Smart Clients

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.

Purpose of this article

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.

Smart Client Architecture

Image 1

Platform

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.

Solution

Sample Smart Client Application

A simple Windows Application project is developed for demonstration on a Smart Client. In this application, we’ll see:

  1. How to launch an EXE application through a URL.
  2. 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.

Image 2

Below are the steps involved in developing this Smart Client application:

Setting project properties to access the URL

  • Click on Project Properties.
  • Go to option tab Publish.
  • On the right hand side of form there are four buttons.
    1. Application Files
    2. Prerequisites
    3. Updates
    4. Options

    Image 3

    Click on the Options button, which will open another window:

    Image 4

  • Select the option for “allow URL parameters to be passed to application”, and click OK.

How to access URL and parameters in the Windows application

The following code snippet is used to access the URL in the form:

C#
using System.Deployment.Application;

ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
String str = ad.ActivationUri.ToString();

Split the URL and retreive the value passed in querystring.

Settings for auto detecting and installing prerequisites

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.

    Image 5

  • Click on Prerequisite button.

    Image 6

  • 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.

Publish the application

  • Build the application.
  • Select Project Properties.
  • Go to Publish tab.
  • Click on Publish Now button.

Make Publish directory as virtual directory

After publishing the application successfully, .NET will create a publish directory under the application folder. Make this directory as a virtual directory.

Sample Web Application

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 web page

  • 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.)

JavaScript
<SCRIPT Language="JavaScript">
<!--

//Adding Dotnet Script START ******************
runtimeVersion = "2.0.0";
directLink = "Bomedit.application";

//function window::onload()
function checkComponent()
{
  if (HasRuntimeVersion(runtimeVersion))
  {
      InstallButton.href="http://<DevelopmentMachineName>" + 
        "/<VirtualDirectory>/<ApplicatonName>.application";
  }
  else{
      //If framework is not installed give the link to install the same;
      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;
}

//Adding Dotnet Script End ******************
-->
</SCRIPT>

Building a Setup Project for Smart Client Applications

  • 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.

Errors Encountered During Development

Below are some of the errors that we faced during development:

Application Identity Not Set

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.

Image 7

File Not Found Exception

<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.

Summary

  • 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.

References

Other Useful Links

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralWorks Great, but a question Pin
Philipose23-Feb-06 12:55
Philipose23-Feb-06 12:55 
GeneralRe: Works Great, but a question Pin
Hemant koppikar27-Feb-06 2:09
Hemant koppikar27-Feb-06 2:09 
GeneralRe: Works Great, but a question Pin
Philipose27-Feb-06 5:51
Philipose27-Feb-06 5:51 
GeneralRe: Works Great, but a question Pin
kuodu24-Mar-06 9:29
kuodu24-Mar-06 9:29 
Generalntegrating 2 web applications in .net Pin
Himam6-Oct-05 20:30
Himam6-Oct-05 20:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.