繁体   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