We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to fix the ThreadStateException (ActiveX control cannot be instantiated) exception when converting HTML to PDF?

Platform: ASP.NET Web Forms |
Control: PDF |
Published Date: February 25, 2016 |
Last Revised Date: September 28, 2018

How to fix the ThreadStateException (ActiveX control cannot be instantiated) exception when converting HTML to PDF?


In the HTML to PDF conversion process, the HTMLConverter throws an exception with the message "ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment."

The HTMLConverter internally makes use of the MSHTML.dll that can run only in the STA mode. Running the application in the MTA mode leads to this exception. 

This can be fixed by any of the following ways:

  1. In the ASP.NET applications, add 'AspCompat=true' in the @page directive.
  2. In ASP.NET MVC, windows or web services and console applications make use of the following code snippet:



You must log in to leave a comment
David Quinn
Sep 27, 2018

In what context should that code be used? You can't put that code outside of a method like you appear to have done ..?

KarthikeyanC [Syncfusion]
Sep 28, 2018

David - You can use the Thread code in your desired method, where you need the conversion part. I will refresh this article for better clarification.


public void HTMLConverter()


Thread t = new Thread(ConvertToPDF); 





private void ConvertToPDF() { //Convert PDF here }


However, if you are trying HTML to PDF converter for the first time, I suggest you to try using our WebKit based HTML to PDF converter.


Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon