none
System.Threading.ThreadStateException: 'ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.' RRS feed

  • Question

  • Hi

    This is an odd one

    Getting the below error message in an existing app which up until this point worked perfectly fine

    System.Threading.ThreadStateException: 'ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.'

    All I had done was add a new tab to my tab control and a webbrowser control.  Now I get that error on a completely unrelated portion of code which has no relation or interaction with the webbrowser control

    I have fixed it for now by adding webbrowser programmatically when needed, rather than in designer

    But wondered if others came across this error and could explain why it happens, as seems odd when just adding a control breaks non-related areas of code


    Darren Rose

    Tuesday, April 9, 2019 7:55 PM

All replies

  • I don't have a clue but if this happened to me I would be going through version control be it TFS, GitHub, SubVersion etc and do compares between before the tab was added and afterwards, especially the project and form designer files.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, April 9, 2019 10:52 PM
    Moderator
  • I don't use version control, but luckily I do regular backups and keep multiple backups, so I have restored back to before the issue and recreated it multiple times this evening.

    It is definitely adding a WebBrowser control via designer which causes it to then happen.  As soon as I remove the control it is okay again.  And if I add control via code rather than designer it is okay as well.

    Very odd, as I say the code which gives error is on a different tab and has no relation to the tab containing browser control or the browser control itself at all - completely non related.


    Darren Rose

    Tuesday, April 9, 2019 11:17 PM
  • Hi,

    I found two links, they are similar to your issue, you can see them.

    https://stackoverflow.com/questions/1418466/single-threaded-apartment-cannot-instantiate-activex-control

    https://stackoverflow.com/questions/8783863/activex-control-8856f961-340a-11d0-a96b-00c04fd705a2-cannot-be-instantiated-be

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 14, 2019 9:15 AM