Apsara vmdotnet's experience in separating C # programs from. NET Framework

Source: Internet
Author: User
Tags virtual environment
I have seen other methods to implement it before, but I still chose vmdotnet, which is also known as the. NET Framework virtual machine, in the popular software Feixin. I believe many people have already read this article. Article But for beginners, I 'd like to mention that there is a vmdotnet folder under your Apsara installation directory. This is the main content we will use. Copy it first!

Here is a brief description of the vmdotnet folder. There is a v2.0.50727 folder under this folder, obviously. net framework' executable file (fetionvm.exe icon) is included in this folder. This is the virtual machine file we will use. We do not need to consider other files. ThisProgramYou can include a parameter, that is, the path of the program to run in this virtual environment. This is like fetionvm.exe c: \ 1.exe. you can also use the relative path: fetionvm.exe 1.exe. of course, the two must be in the same directory. In this case, the vmdotnet.logfile is used to record the error message when fetionvm.exe is used. It is mainly because the path is incorrect and the corresponding program cannot be found. After learning about this folder, we can start it!

Copy this folder to the DEBUG directory of your project. The name of my existing project is picprocessor, And the executable file generated is. Of course, you can also set it as needed, if you put it somewhere else, you should pay attention to the path.

Here we need to create a new C # application project. I name it picstart, delete form1.cs, or create a new console program and write the following in program. CS:Code:

Using system;
Using system. Collections. Generic;
Using system. Windows. forms;

Namespace picstart
{
Static class Program
{
/// <Summary>
/// Main entry point of the application.
/// </Summary>
[Stathread]
Static void main ()
{
// The following code calls an external program
System. Diagnostics. processstartinfo info = new system. Diagnostics. processstartinfo ();
Info. filename = "vmdotnet \ v2.0.50727 \ fetionvm.exe"; // The external program you want to call
Info. Arguments = "picprocessor.exe"; // call the parameters of an external program. This is the executable file of the image processing project. Note that it is not the executable file of the current project.
System. Diagnostics. Process proc;

Try
{
//
// Start an external program
//
Proc = system. Diagnostics. process. Start (Info );
}
Catch (system. componentmodel. win32exception E)
{
Console. writeline ("the specified program file cannot be found. \ R {0} ", e );
Return;
}
}
}
}

After this project is completed, we will generate this project. At this time, we can start to create the installation file of the program.

In the past, when we used vs2005 to install the installation package, we could choose. net Framework is integrated, but now we don't need it. Please remove all the corresponding options. If you still don't use the vs2005 installation and deployment functions, please visit this website. Http://www.vs2005.com/Setup/205/1/default.aspx

complete. The specific operation methods are shown in the above link. Then, generate the installation package. If the size of the generated installation package is preferred, vmdotnet will occupy about 10 MB of space, and the size of your program will be the size of the Installation File, more than 20 mb. net Framework is much smaller, and the installation speed is much faster. NET framework can also run on machines

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.