Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the implementation method of compiling another program in C # program?

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to compile another program in the C# program. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Before compiling a C# program, you need to use a compilation tool devenv.exe provided by VS2005. You can use the console command in the VS installation directory\ Common7\ IDE:

Devenv / rebuild debug "[sln path]"

2. C # program compiles to run the specified program in the code, you can use the process method:

Using System.Diagnostics System.Diagnostics.Process.StartInfo info=new StartInfo (); info.FileName= "specific programs you want to use"; Info.Arguments= "files to open:; System.Diagnostics.Process.Start (info)

3. A problem will be encountered in the actual use of C # program compilation: if each person's VS installation directory is different, the path to call devenv in the program is different. The way to solve this problem is to read the ApplicationPath key value of vs in the registry (which was described earlier). To sum up, the implementation is as follows:

Using System.Diagnostics; using Microsoft.Win32; private const string REGISTKEY = "SOFTWARE\\ Microsoft\ MSEnvCommunityContent\\ ContentTypes\ Addin\\ ContentHosts\\ 1.0\ Visual Studio 2005"; RegistryKey rkey = Registry.LocalMachine; / / The second parameter tells it to open the key as writable RegistryKey rkey1 = rkey.OpenSubKey (REGISTKEY, true); string visualStudio8Path = rkey1.GetValue ("ApplicationPath"). ToString (); ProcessStartInfo startInfo = new ProcessStartInfo (visualStudio8Path) StartInfo.Arguments = "/ rebuild debug" + "[sln path]"; Process process = new Process (); process.StartInfo = startInfo; process.Start (); process.WaitForExit (); the above is how to compile another program in the C # program. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report