我试图实例化 WebBrowser 类的对象以在页面上进行查询并返回结果,但是会生成错误:
由于当前线程不在未处理的容器中,因此无法创建activeX控件'8856f961-340a-11d0-a96b-00c04fd705a2'的实例。
我试图以不同的方式实现这一目标,但没有达到预期的结果。
这是我的代码
// At beginig of class Form
public delegate void DataRecieved(ConexionTcp conexionTcp,string data);
public event DataRecieved OnDataRecieved;
private void Form1_Load(object sender,EventArgs e)
{
OnDataRecieved += MensajeRecibido;
}
private void MensajeRecibido(ConexionTcp conexionTcp,string datos)
{
WebBrowser myweb= new WebBrowser();
myweb.Navigate("http://localhost/Php/Final3");
myweb.Document.GetElementById("user").InnerText = "user";
myweb.Document.GetElementById("pass").InnerText = "pass";
myweb.Document.GetElementById("Encode").InvokeMember("Click");
if ("resultado" == myweb.Document.GetElementById("pass_sha_hash").InnerText)
{
textbox1.Text="Completado";
}
}
有人能找出我在做什么错吗?