1

我正在尝试使用 csc 将我的 C# 程序编译为独立的 .exe,但不知何故我无法从该项目的资源中包含两个 .exe。我在最终的standalone.exe 中需要它们。csc 告诉我它们是二进制文件而不是文本文件(嗯,呵呵)。任何帮助,将不胜感激 !:3

编辑:使用/resource:我把它缩小到这个:

http://puu.sh/38mMq.png

此外,如果它很重要:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        bool is64bit = !string.IsNullOrEmpty(
        Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"));
        if (is64bit == true)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo("devcon64.exe");
            startInfo.Arguments = "restart =display *";
            Process.Start(startInfo);
        }
        else
        {
            ProcessStartInfo startInfo = new ProcessStartInfo("devcon32.exe");
            startInfo.Arguments = "restart =display *";
            Process.Start(startInfo);
        }
    }
}
}
4

2 回答 2

0

假设您希望这些作为嵌入式资源,您应该能够只使用该/resource标志:

csc Foo.cs /resource:Bar.exe /resource:Baz.exe

如果您希望它们不是嵌入式资源,则需要澄清您的要求。

于 2013-06-04T19:40:54.110 回答
0

从来没听说过。您必须单独包含其他可执行文件。

如果可执行文件是自包含的,并且没有您需要发布的依赖项,那么您可以将可执行文件作为资源包含在主可执行文件中,然后将其提取并保存到磁盘并在需要时执行。它仍然需要一些跨进程通信才能获得结果,但是您必须交付一个可执行文件。

原始答案

ps你也可以阅读 类似的主题

于 2013-06-04T19:41:01.680 回答