C # block module ABC (2)

Source: Internet
Author: User

5. Deploy the application in C #

Deploying a project in Visual Studio. NET is very simple. Most programs can be automatically completed through some convenient wizard without any effort. However, please note that you may also need to install Windows component update Beta 1 on your machine. Of course, the Microsoft. NET Framework is also required. Note: Microsoft says that the current deployment may be ineffective in the future.

Once the application is written in Visual Studio, you can start the deployment as follows:

First, select Add new project file from the File menu:

Then, select set and deploy the project. Visual Studio provides a list of options for deploying the project, and determines whether to deploy the project to the Web. the form of the cab file is still in the form of a Windows Setup program:

The following table lists the settings of different types of project files and their descriptions and uses:

Project setting type Description Chinamoocs
CAB Engineering A Microsoft compressed cabinetfile, which can be opened with cabarc.exe. Deploy applications that can be downloaded from the Internet.
Deployment wizard Create a deployment file for the web, or create a deployment file for the windows Installer that uses the. msi setting file, and deploy them on a remote or local machine. Used to create setup files and deployment files for the project at the same time.
Merge Module Package components shared by different applications. Deploy a component library.
Web Settings wizard Create an installer for a web-based application, which is installed in the virtual root directory of a web server. Creates an installer for the web server.
Setup Wizard Use a. msi setting file to create a setting file for the windows installer. Creates a configuration file. It seems that only the. msi file is created, but everything is compressed in this file. Store the program in the program file directory during runtime.

We chose to use the Setup Wizard to deploy this specific application. The setup wizard provides a good step by step dialog box for creating and setting project files:

 

As shown in the dialog box, the wizard creates an installer that you can use to install the project file. On the next screen, ask which type of installer you want to create:

 

We want a completely old-fashioned Windows Installation Style, so select "Create a setup for a rich client application ". The following screen shows the file to which you want to install it:

If you only want to deploy an application without source code or documentation, select "Primary output" (Basic output ). In this way, necessary exe files and dll files are deployed for the application.

The following screen prompts you to include additional files in the installation file, such as readme.txt and web pages. In the case of Hangman, we added a sound file:

The last screen is a report that tells you what is done and where the created vdp (visual deployment project) is:

Click "Finish" to create a directory for the deployment. Now you need to create a project file to deploy it. Therefore, select "create solution" from the "Create" menu, and create the MySetupProject required to install the application. msi file.

After creating MySetupProject. msi, double-click it to start the installation program. For most installers, this means that all necessary files are copied to the directory under program files. In the hangman project files, these files refer to all System. xxx. dll files and Microsoft. xxx. dll files (CLR libraries.


. Obtain the Host IP Address

You can use the. Net DNS class to obtain a host name or IP address of a given host. To use the DNS class in a program, you must include System. Net:

Include System. Net Reference

For exampleHttp://www.mindcracker.com/IP address. The following code completes this task:

// Call DNS. GetHostName to get IPHostEntry and get the IP address list.

IPHostEntry ipEntry = DNS. GetHostByName ("www.mindcracker.com ");

IPAddress [] IpAddr = ipEntry. AddressList;

For (int I = 0; I <IpAddr. Length; I ++)

{

Console. WriteLine ("IP Address {0 }:{ 1}", I, IpAddr [I]. ToString ());

}

In addition, you can use GetHostName without parameters to return the Host Name of the local machine:

String strHostName = DNS. GetHostName ();

Then pass the host name as a parameter to GetHostByName to obtain the IP address information of the local machine.

7. How to call the dialog box?

MessageBox. Show ("Inavlid File", "File Open Result", MessageBox. OKCancel | MessageBox. IconHand );

8. How do I call Windows APIs?

Calling an API in C # is the same as calling an API in VB. We should know the api dll name and use sysimport to introduce it. The following example shows how to call the MessageBox API:

Using System;

Class callAPICls {

[Sysimport (dll = "user32.dll")]

Public static extern int MessageBoxA (int h, string m, string c, int type );

Public static int Main ()

{

Return MessageBoxA (0, "Hello World! "," Caption ", 0 );

}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.