简体   繁体   中英

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

I am using Visual Studio 2008 Integrated Shell with the F# CTP (October). Everything works fine, but when I am trying to open System.Windows.Forms , VS gives an error: the namespace 'Windows' is not defined .

However, it works when I try to open the namespace in F# interactive .

What am I doing wrong?

For F# Visual Studio projects you will need to right click on your project References entry and walk through the Add Reference dialog. F# Interactive includes references to several frequently used assemblies by default whereas F# application projects only get FSharp.Core, mscorlib, System, and System.Core by default.

The System.Windows.Forms namespace lives in the System.Windows.Forms.dll. You'll need to make sure it's loaded. In fsi use the following to load it from the gac.

#r "System.Windows.Forms";;

then you can use as normal

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM