I am not using any thread in my application but I am getting this exception:
Additional information: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
When I am Initializing WebBrowser
in my web application.
WebBrowser wb = new WebBrowser();
This is my normal flow of calling this method.
Page_Load()
{
TestWebBrowser("www.something.com")
}
static string TestWebBrowser(string url);
{
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnaenter code herebled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
mshtml.IHTMLDocument3 documentAsIHtmlDocument3 = (mshtml.IHTMLDocument3)wb.Document.DomDocument;
var content = documentAsIHtmlDocument3.documentElement.innerHTML;
return content ;
}