문제

Simple question:

In F# Interactive, this does not work (it shows no dialog):

open System.Windows.Forms
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()

This code does work, after I first do a simple MessageBox:

open System.Windows.Forms
MessageBox.Show("Now it works!")
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()

This code also works, after first showing a Form:

open System.Windows.Forms
let frm = new Form()
frm.Show()
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()

This code however does not show any forms, not even the Messagebox:

open System.Windows.Forms
let dlg = new OpenFileDialog()
let res = dlg.ShowDialog()
MessageBox.Show("Now it does not work...")

It seems the OpenFileDIalog blocks on something, if it does not have some other form warm/ load something first, no idea what.

Any ideas what would make the OpenFileDialog work straight away?

Using Microsoft (R) F# 2.0 Interactive build 4.0.40219.1

Thanks, GJ

도움이 되었습니까?

해결책

The windows are there, they just appear behind the Visual Studio UI, so it's easy not to notice them. I'm not sure why they do not appear in the foreground.

A quick test in FSI from the command line (i.e. not the hosted VS one) indicates the windows come to the foreground in this case.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top