Using a System.Windows.Forms.WebBrowser inside ASP web form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Q29kZVJhem9y?=

    #1

    Using a System.Windows.Forms.WebBrowser inside ASP web form

    I am converting a windows application which contains a web browser control
    into an ASP.net application.

    The Windows project references all manner of html controls in the WebBrowser
    control and retrieves values using the HtmlControlColl ection class etc.

    I was hoping I was going to be able to work with the
    Windows.Forms.W ebBrowser object from inside my ASP.net webform by simply
    adding a reference to System.Windows. Forms and doing code like below:

    WebBrowser webBrowser = new WebBrowser();
    webBrowser.Docu mentText = "<html><bod y>my document</body></html>;
    HtmlDocument htmlDocument = webBrowser.Docu ment;

    However, it blows up with the following error:
    ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be
    instantiated because the current thread is not in a single-threaded
    apartment.

    Is there any way to get round this problem. It would save having to totally
    rewrite this project.

    Many thank,

    CodeRazor
Working...