【发布时间】:2013-09-17 04:48:27
【问题描述】:
简单的问题:
在 F# Interactive 中,这不起作用(它不显示对话框):
open System.Windows.Forms
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()
在我第一次做一个简单的 MessageBox 之后,这段代码确实有效:
open System.Windows.Forms
MessageBox.Show("Now it works!")
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()
此代码在第一次显示表单后也有效:
open System.Windows.Forms
let frm = new Form()
frm.Show()
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()
然而,这段代码没有显示任何形式,甚至没有显示消息框:
open System.Windows.Forms
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()
MessageBox.Show("Now it does not work...")
似乎 OpenFileDIalog 阻塞了某些东西,如果它没有其他形式的温暖/先加载某些东西,不知道是什么。
有什么想法可以让 OpenFileDialog 立即工作吗?
使用 Microsoft (R) F# 2.0 Interactive build 4.0.40219.1
谢谢,GJ
【问题讨论】:
-
在 3.0 和 3.1 FSI 中对我来说很好,可能是一个老错误。
-
刚刚在 VS2012/FSI 11.0.60610.1 上尝试过(因为兼容性而使用 2010),但我得到了与 2010 完全相同的行为..
-
在 11.0.60610.1 上为我工作。请注意,窗口会弹出 在 VS UI 的后面,这并不理想,但它们就在那里。
-
你是对的。 OpenFileDialog 在那里,但在 VS 后面。当我最小化 VS 时,我看到了它。不同之处在于,当我首先打开 Form 或 MEssageBox 时,OpenFileDialog 会在任务栏上获得一个图标,否则不会。无法将评论标记为答案...
-
酷,很高兴它正在工作。
标签: winforms f# f#-interactive