Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top