With the gaining popularity of the Web, it is becoming increasing important, if not expected, to be able to download and run applications by simply going to a website. .NET provides several mechanisms for you to make this task easier. You can choose to deploy an application from a URL or your can create a smart client application that is capable of downloading itself.
One of the coolest things with .NET is the attempts that the Framework makes to resolve the locations of an assembly it wants to bind. Because the Framework looks in so many locations, and one of them is the application base, you can simply set up an application for deployment from a URL by dropping all the required assemblies in a folder on the web server. To illustrate this point, take SimpleApplication.exe and the assembly that it references, SimpleApplicationLibrary.dll, and place them in a folder called SimpleExample off of the root of your web server.
TIP
Because the web server that you use to deploy your application simply serves as a distribution mechanism, you do not need to have the .NET Framework installed on that web server. In fact, the web server does not even have to be a Windows machine.
When the files are in this folder, you can open the Internet Explorer and, as shown in Figure 20.1, type the following URL:
http://localhost/SimpleExample/SimpleApplication.exe
When the application appears, click the button and a message should appear, as shown in Figure 20.2. The text for this message is not contained within the SimpleApplication.exe application, but is stored in the SimpleApplicationLibrary.dll assembly. This shows that the .NET Framework not only downloaded the requested file, but when needed, also downloaded the required assembly.
A smart client is an application that captures the best features of rich client and web client applications and adds to them. One of the features of a smart client is that it is centrally deployable and self-updating. That means when a smart client is deployed, the assemblies and required files should be deployed in one location and the client application should be capable of retrieving all the necessary files from that location. It also means that if any of the assemblies are updated, the smart client should be capable of detecting that a newer version is available and retrieve that version of the assembly.
Unlike the example in the previous section, when the application was started from a URL and it automatically loaded the referenced assembly from that location, a smart client application is generally stored on the user's machine. When the smart client application starts, it checks a predefined location for the required assemblies and if a newer version is available, it downloads this version to the client machine. In .NET, this is possible by using the Assembly.LoadFrom method. By using this method, the .NET Framework will automatically check for, download, and use the latest version of the assembly. Listing 20.5 shows the source code for a pseudo smart client application. Although this application is capable of meeting the centrally deployable requirement of being a smart client, it does not meet all the requirements, so we will call it a pseudo smart client.
3.139.240.119