【问题标题】:Compile MFC Code From C# Windows Application从 C# Windows 应用程序编译 MFC 代码
【发布时间】:2010-10-05 10:37:59
【问题描述】:

我正在构建一个 C# Windows 应用程序来编译和构建 MFC 代码,我用谷歌搜索了很多,我发现这个线程非常有用 Thread 但我面临两个问题;

&在 oralce 8 配置中构建项目

Oralce 8 配置:a) 调试 b) 发布

Oralce 10 配置:a) 调试 (Ora 10) b) 发布 (Ora 10)

但是什么时候在命令行中传递这些值,例如;

devenv /build 调试 (Ora 10) "c:\MySolutions\Visual Studio Projects\MySolution\MySolution.sln"

它不会在命令行的给定配置下构建它

2) 与 C# 中的 Process 类相关我从 Process.Start(Path to CMD) 调用 CMD,它会启动命令提示符,但在打开窗口后它会关闭它(我说关闭这是因为我在任务管理器中检查了进程选项卡,但它不存在)。

请帮帮我。

谢谢

【问题讨论】:

    标签: c# command-line mfc build compilation


    【解决方案1】:

    对于 #2 - 发布一些代码 - 这是我的:

    using System;
    using System.Diagnostics;
    using System.ComponentModel;
    
    namespace MyProcess
    {
        class MyProcess
        {
            public static void Main()
            {
               string CmdPath, CmdArgument, FrameworkPath;
               CmdPath = "cmd.exe";
               CmdArgument = "";
               FrameworkPath = "C:\\";
               ProcessStartInfo CmdLine = new ProcessStartInfo(CmdPath, CmdArgument);
               CmdLine.WindowStyle = ProcessWindowStyle.Maximized;
               CmdLine.WorkingDirectory = FrameworkPath;
               CmdLine.UseShellExecute = false;
               Process CmdProcess = new Process();
               CmdProcess.StartInfo = CmdLine;
               try
               {
                  CmdProcess.Start(); 
               }
               catch (Exception e)
               {
                   Console.WriteLine(e.Message);
               }
            }
        }
    }
    

    【讨论】:

    • ProcessStartInfo CmdLine = new ProcessStartInfo(CmdPath, CmdArgument); CmdLine.WindowStyle = ProcessWindowStyle.Maximized; CmdLine.WorkingDirectory = 框架路径; CmdLine.UseShellExecute = false;进程 CmdProcess = new Process(); CmdProcess.StartInfo = CmdLine; CmdProcess.Start();
    • 好的 - 修改示例以使用您的代码,我必须初始化 CmdPath、CmdArgument 和 FrameworkPath。下次发布一个至少可以编译的代码示例,我们可以修复它 -
    【解决方案2】:

    对于您问题的第 1 部分,我很确定您需要在任何带有空格的参数周围加上引号,因此该行应该是这样的:

    devenv /build "调试 (Ora 10)" "c:\MySolutions\Visual Studio Projects\MySolution\MySolution.sln"

    这假设您的解决方案中有一个名为“Debug (Ora 10)”的配置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-14
      • 2012-04-17
      • 1970-01-01
      • 1970-01-01
      • 2013-10-24
      • 2010-10-14
      • 1970-01-01
      • 2021-11-17
      相关资源
      最近更新 更多