簡體   English   中英

F#:嘗試打開System.Windows.Forms時未定義名稱空間

[英]F#: Namespace not defined when trying to open System.Windows.Forms

我正在使用Visual Studio 2008 Integrated Shell和F#CTP(十月)。 一切正常,但是當我嘗試打開System.Windows.Forms時 ,VS會出錯: the namespace 'Windows' is not defined

但是,當我嘗試在F#interactive中打開命名空間時,它會起作用。

我究竟做錯了什么?

對於F#Visual Studio項目,您需要右鍵單擊項目的References條目並瀏覽Add Reference對話框。 F#Interactive默認包含對幾個常用程序集的引用,而F#應用程序項目默認只獲取FSharp.Core,mscorlib,System和System.Core。

System.Windows.Forms命名空間位於System.Windows.Forms.dll中。 你需要確保它已加載。 在fsi中使用以下命令從gac加載它。

#r "System.Windows.Forms";;

然后就可以正常使用了

let w = new System.Windows.Forms.Form() ;;
w.Show();;
w.Close();;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM