Internet-based deployment in .NET

xiaoxiao2021-03-06  107

To use this deployment, the client must have .NET Framework and have an Internet connection. In addition, the system for deployment must be a web server installed with .NET and IIS.

The deployed application is placed in a directory on the server, and you can use a URL to locate. Then, the application can start by one of the following two ways:

On the web page, click the link to the startup EXE that is used on the server.

Use a small "startup" application to point to the primary application on the server. This starter is actually a local shortcut to the application.

These two are downloaded from the Internet and executed locally.

The following is a specific steps:

1: Strictly construct a form application in accordance with the development of a Windows Form Application

2 After the development is complete, change the compilation option for all Windows Forms items in the application to create a DLL file. Suppose we have created an appdll1.dll.

3 Copy all DLLs containing the application to a web folder. This includes the application's DLL for launching a Windows Form, as well as components or other DLLs required for the application.

4: Create a startup program, mainly using reflection function. Start a new application. Place a button on the form. The code is as follows:

Using system.reflection;

Try

{

String surl = "htpp://mywebserver/myapp/Appdll1.dll";

AskEMBLY OBJASS = askEMBLY.LOADFROM (SURL); // Get an assembly

TYPE FORMTYPE = Objass.gettype ("MyProjectName.StartForm"); // Get the type in the list in the program

Object obj = activator.createInstance (formType); / / Create an object based on the type

Form f = (form) OBJ;

f.show ();

}

Catch (Exception EX)

{

Messagebox.show (ex.Message);

}

When we launch an app, look at the procedures that have occurred in the background:

When startup, it requests an assembly that has not yet existed on the client, which will automatically get the assembly from the deployment web server and put it on the local client. It resides in the client's application download cache. Once you will The assembly is placed in the app download cache on the client, which can be loaded and run from the assembly. This includes all required forms (forms are also a class). Or all other objects belong to the application. We can view Download which assemblies have been downloaded:

> GACUTIL / LDL This command line can view the list of downloads on the client

The application is controlled by the form that is loaded from the web server, which can perform operations and load other forms as needed. If additional forms are loaded from the same program, those forms are automatically loaded without any special logic.

When .NET looks up the assembly in the download cache, if it is found, it will check the version of the assembly. At the same time, the current version of the same assembly is also checked on the web server (if the Internet connection is available). There is a new version of the assembly, download the new version to cache and replace the original version. This makes the auto-deployment automatically.

If the application offline mode (INTERNET is not available). Then you will skip the current version test. And use the original version in the download cache.

转载请注明原文地址:https://www.9cbs.com/read-104114.html

New Post(0)