G
Guest
I don't understand what's going on in the following program. I believe it
should simply create a form with a browser in it and navigate that browser to
Google. However, the constructor for the WebBrowser is throwing a
ThreadStateException saying ActiveX control
'8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the
current thread is not in a single-threaded apartment. Any ideas what's going
on?
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Project1
{
class Class1
{
public static void Main()
{
Application.Run(new Form1());
}
}
class Form1 : Form
{
public Form1()
{
WebBrowser b = new WebBrowser();
b.Navigate("www.google.com");
this.Controls.Add(b);
}
}
}
Thanks
-Warren
should simply create a form with a browser in it and navigate that browser to
Google. However, the constructor for the WebBrowser is throwing a
ThreadStateException saying ActiveX control
'8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the
current thread is not in a single-threaded apartment. Any ideas what's going
on?
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Project1
{
class Class1
{
public static void Main()
{
Application.Run(new Form1());
}
}
class Form1 : Form
{
public Form1()
{
WebBrowser b = new WebBrowser();
b.Navigate("www.google.com");
this.Controls.Add(b);
}
}
}
Thanks
-Warren