私はWinFormsを初めて使用し、WebBrowser
GNU/LinuxのコントロールをMonoで使用しようとしています。正常に動作しますが、フォームを閉じると奇妙な警告が表示され、。を含む別のフォームを作成しようとするとアプリケーションがフリーズしますWebBrowser
。
実際、ブラウザを閉じるまで、必要な数のブラウザを起動できます。次に、新しいアプリを作成すると、アプリがフリーズします。
サンプルコードは次のとおりです。
public class TestForm : Form
{
Button button = new Button();
public TestForm()
{
button.Parent = this;
button.Text = "Run browser";
button.Click += button_Click;
}
[STAThread]
public static void Main()
{
Application.Run(new TestForm());
}
public void button_Click(object sender, EventArgs e)
{
new MyBrowser("www.google.com").Show();
}
}
class MyBrowser : Form
{
WebBrowser browser = new WebBrowser();
public MyBrowser(string url)
{
browser.Parent = this;
browser.Dock = DockStyle.Fill;
browser.Navigate(url);
}
}
これが私が得る警告です:
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x2800094 unexpectedly destroyed
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x2800093 unexpectedly destroyed
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x280007e unexpectedly destroyed
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x280007d unexpectedly destroyed
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x280001c unexpectedly destroyed
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x280001b unexpectedly destroyed
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x280001a unexpectedly destroyed
(essai.exe:9108): Gdk-WARNING **: GdkWindow 0x2800016 unexpectedly destroyed
だから私の質問は:私は何が間違っているのですか?問題がMonoに起因する可能性はありますか?
更新:Windowsでは、の定義の[STAThread]
前に追加すると機能します。Main