C # building block module ABC (ii) deploying applications in C #

Source: Internet
Author: User
Tags include root directory visual studio
Programs deploy applications in C #

Deploying the project in Visual Studio.NET is simple. Most programs can be done automatically with some handy wizards, without any effort. Keep in mind, however, that you may also need to install the updated beta version 1 of the Windows component on your machine. Of course, Microsoft is also required. NET Framework. Note also that Microsoft says the current deployment may not work in the future.


Once you have finished writing your application in Visual Studio, you can start the deployment by following these steps:


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



Then, when you select Setup and Deployment Engineering, Visual Studio provides a list of options for deployment engineering, depending on whether you want to deploy to the web or not, or the form of a compressed. cab file or a Windows Setup program:




The following table is the different types of engineering file settings and their description and purpose:


Project Setup Type description purpose

Cab Project: A Microsoft compressed cabinet file that can be opened with Cabarc.exe. Used to deploy applications that can be downloaded from the Web.

Deployment Wizard: Create a deployment file for the Web, or create a deployment file for the Windows Installer that uses the. msi settings file, and deploy them to a remote machine or to a local machine. Used to create both the setup and deployment files for the project.

Merge Modules: Package components that are shared by different applications. Deploy a component library.
The Web Setup Wizard creates an installer for a web-based application that will be installed in the virtual root directory of a Web server. Use to create an installer for a Web server.

Setup Wizard: Create a settings file for Windows Installer using an. msi settings file. Used to create a settings file. It looks as if you only created an. msi file, but everything is compressed into this file. The runtime places the program in the program file directory.



We chose to use the Setup Wizard to deploy this particular application. The Setup Wizard provides a good step through step dialog box for creating a Setup Engineering file:



As indicated in the dialog box, the wizard creates an installer that you can use to install the engineering files. The next screen asks which type of installer you want to create:



What we want is a completely old-fashioned Windows installation style, so select "Create a setup for a rich client application". The next screen prompts which file to install:



If you just want to deploy an application that has no source code or documentation, select Primary output. This deploys the necessary EXE files and DLL files for the application.

The next screen prompts you to include additional files that Microsoft does not include in the installation file, such as Readme.txt, Web pages, and so on. In the case of hangman, we added a sound file:



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



After clicking Finish, a directory is created for the deployment. Now you need to create a project file to deploy it, so choose Create Scenario from the Create menu (build Solution), which creates the Mysetupproject.msi files that are required to install the application.


After you create the Mysetupproject.msi, double-click it to start the installer. For most installers, this simply means copying all the necessary files to the directory under Program files. In the Hangman engineering file, these files refer to all System.xxx.dll files, Microsoft.xxx.dll files (CLR libraries), NLP files (Common language resources), runtime class library mscorlib. DLLs, Mngdist.dll (which may be managed to send), xxx.wav (sound files), and of course executable files, here are Hangman.exe.


Get the IP address of the host

can be used. NET to obtain a host name or the IP address of a given host. To use a DNS class in your program, you need to include System.Net:


Include System.Net Reference


For example, to obtain http://www.mindcracker.com/IP address, the following code will complete 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.tostring ());


}


In addition, GetHostName can return the host name of the local machine using a parameterless:


String strhostname = DNS. GetHostName ();


The host name is then passed as a parameter to gethostbyname to obtain the IP address information of the local machine.


How do I invoke a dialog information box?


MessageBox.Show ("Inavlid file", "File Open result", Messagebox.okcancel | Messagebox.iconhand);


How do I invoke the Windows API?

Calling an API in C # is the same as calling an API in VB. We should know the DLL name of the API and introduce it using Sysimport. The following example shows how to invoke 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.