2010-04-01 165 views
0

我一直在玩沒有Visual Studio創建小窗口窗體應用程序。防止命令窗口顯示何時編譯窗口窗體應用程序

我在Notepad ++中創建我的源代碼,並使用NAnt構建文件進行編譯。

當我運行應用程序時,還會顯示一個命令窗口以及應用程序窗口。我怎樣才能防止顯示的命令窗口?

using System; 
using System.Drawing; 
using System.Windows.Forms; 
using System.Media; 
using System.IO; 

namespace mynamespace 
{ 
    class MyForm : Form 
    { 
     public Button btnPlay; 

     MyForm() 
     { 
      this.SuspendLayout(); 

      this.Text = "My Application"; 

      InitialiseForm();  

      this.ResumeLayout(false); 
     } 

     private void InitialiseForm() 
     { 
      btnPlay = new Button(); 
      btnPlay.Location = new System.Drawing.Point(30,40); 
      btnPlay.Text = "Play"; 
      btnPlay.Click += new System.EventHandler(btnPlay_Click); 

      this.Controls.Add(btnPlay); 
     } 

     protected void btnPlay_Click(object sender, EventArgs e) 
     { 
      string wav = "testing123.wav"; 
      Stream resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(wav); 
      SoundPlayer player = new SoundPlayer(resourceStream); 
      player.Play(); 
     } 

     public static void Main() 
     { 
      Application.Run(new MyForm()); 
     } 
    } 
} 

構建文件

<?xml version="1.0"?> 
<project name="myform" default="build" basedir="."> 
    <description>My Form app</description> 
    <property name="debug" value="true" overwrite="false"/> 
    <target name="clean" description="Remove all generated files"> 
     <delete dir="build"/> 
    </target> 
    <target name="build" description="Compile the source" depends="clean"> 
     <mkdir dir="build"/> 
     <csc target="exe" output="build\MyForm.exe" debug="${debug}" verbose="true"> 
      <resources> 
       <include name="app\resources\*.wav" /> 
      </resources> 
      <sources> 
       <include name="app\MyForm.cs"/> 
      </sources> 
     </csc> 
    </target> 
</project> 

回答

2

好,我有它,我需要指定目標= 「winexe」,而不是目標= 「EXE」