【发布时间】:2011-10-05 17:18:29
【问题描述】:
此 C# 代码用于运行我合并在一起的 Winform 应用程序。我想从那个 C# 代码创建一个 exe 文件。
如何做到这一点?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public class Form1 : Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
public Form1()
{
InitializeComponent();
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
}
#endregion
}
}
【问题讨论】:
-
您是否尝试过使用 C# 编译器 (
csc.exe)? -
我假设你没有视觉工作室?从 Microsoft 获取 Visual C# Express 2010。它是免费的!
-
对不起......但我知道你在对我说什么......所以我知道像VS或任何东西这样的IDE以及如何使用它!我希望我的 C# winform 生成一个 exe 文件!好的?! ...实际上...我想从我的项目(Windows 窗体应用程序)中生成 exe 文件!!! ...我正在创建一个像visual studio这样的程序可以创建exe文件...但是比VS简单!!!我想要一些代码从我在第一篇文章中写的文件中生成 exe 文件!!!!
-
我认为您想从您的应用程序构建 C# 代码。看这里:stackoverflow.com/questions/7264682/…