2

Recently I've been using TryFSharp.org in an attempt to learn F# in my spare time.
There's loads of really good examples on http://fssnip.net/ which I've been looking at for inspiration.

Lots of the UI examples have code such as:

open System
open System.Drawing
open System.Windows.Forms
...
form.Show()
// Run the application (in compiled application)
Application.Run(form)

Unfortunately when I load these into TryFSharp.org I get compilation errors on the open System.Drawing.

Is there something I'm missing that would enable these examples to work? An example FSharp script is here:

http://fssnip.net/p

If you click on the tryfsharp.org button it'll load in the browser but it will show compilation errors.

--- EDIT ---

As pointed out below it's not expected for System.Drawing to be available within the browser. However I also have issues with the namespaces System.Windows etc.

For instance

open System.Windows

fails with "The namespace 'Windows' is not defined"

Tried in both IE10 and Google Chrome.

--- END EDIT ---

4

1 回答 1

5

System.Drawing 允许您访问 GDI 图形功能,而 System.Windows.Forms 允许您访问 Windows 窗体功能。这些都不能在浏览器中使用。

如果你想这样做,你需要从标准的 .net 编译器而不是在 silverlight 中运行的有限功能编译器编译它。

System.Windows.Controls银光

当我将它输入 TryFSharp 编辑器时,由于Windows某种原因它无法识别命名空间,但是当我运行脚本时,它执行得很好。

System.Windows.Drawing

System.Drawing 命名空间提供对 GDI+ 基本图形功能的访问。

GDI

GDI 可用于所有基于 Windows 的应用程序。

这意味着不是Silverlight。

System.Windows.Forms

System.Windows.Forms 命名空间包含用于创建基于 Windows 的应用程序的类,这些应用程序充分利用 Microsoft Windows 操作系统中提供的丰富用户界面功能。

并非 TryFSharp 先前迭代中提供的所有功能当前都可用。在此处查看当前访问 Cavnas 的方式。

于 2013-04-26T13:55:55.610 回答