编写脚本时,如:
#light
#r "System.Xaml.dll"
#r "WindowsBase.dll"
#r "PresentationCore.dll"
#r "PresentationFramework.dll"
open System
open System.Windows
let win = new Window()
win.Title <- "Say Hello"
win.Show()
#if COMPILED
[<STAThread()>]
do
let app = new Application() in
app.Run() |> ignore
#endif
在源文件的文本下方,我已将System.Xaml,WindowsBase,PresentationCore和PresentationFramework添加到我的参考文献中。
open System
open System.Windows
let win = new Window()
win.Title <- "Say Hello"
win.Show()
#if COMPILED
[<STAThread()>]
do
let app = new Application() in
app.Run() |> ignore
#endif
我收到消息:类型&#34; Window&#34;没有定义。有人能告诉我如何从源文件访问/引用名称空间System.Windows和System.Windows.Controls吗?
由于
编辑:添加了截图
在继续之前,我想将脚本(带有UI)转换为源文件。
答案 0 :(得分:0)
在“解决方案资源管理器”中,选择项目。在“项目”菜单上,单击“添加引用”。或者:项目 - &gt;添加参考
将打开“添加引用”对话框。选择指示要引用的组件类型的选项卡。
选择:
WindowsBase.dll
PresentationCore.dll
PresentationFramework.dll
System.Xaml.dll
或下载模板:
https://visualstudiogallery.msdn.microsoft.com:443/e0907c99-bb04-4eb8-9692-9333d5ff4399