温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

在C#程序编译另一个程序的实现方法是怎样的

发布时间:2021-11-23 23:14:13 来源:亿速云 阅读:97 作者:柒染 栏目:编程语言

本篇文章为大家展示了在C#程序编译另一个程序的实现方法是怎样的,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

1、C#程序编译编译前,要用到VS2005提供的一个编译工具 devenv.exe,这个在VS安装目录\Common7\IDE 下可以使用控制台命令:

devenv /rebuild debug "【sln path】"

2、C#程序编译在代码中要运行指定的程序,可以使用process方法:

using System.Diagnostics  System.Diagnostics.Process.StartInfo   info=new StartInfo();   info.FileName="你想要用的特定的程序";   Info.Arguments="要打开的文件:;   System.Diagnostics.Process.Start(info);

3、在C#程序编译的实际使用过程中会遇到一个问题:各人VS安装目录不同,程序中调用devenv的路径就不同。解决这个问题的方法就是读取注册表中的vs的ApplicationPath键值(这个在前面有过介绍)综上,实现方法如下:

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();

上述内容就是在C#程序编译另一个程序的实现方法是怎样的,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI