How to resolve msg "ActiveX control cannot be instantiated b/c the current thread is not in a single-thread apartment"

Giacomo Raucci 346 Reputation points
2022-01-11T15:52:53.517+00:00

In the process of converting from a VBA app to a Winform App using Visual Studio 2019 Windows Forms App (.NET Framework). Once I added an InkPicture control, I get a message "ActiveX control nnn cannot be instantiated because the current thread is not in a single-thread apartment. Suggestions? Thanks for your help.

Developer technologies | Windows Forms
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.6K Reputation points
    2022-01-11T15:58:31.293+00:00

    Try opening the Program.cs, find the Main function and make sure that it has the [STAThread] attribute:

    [STAThread]
    static void Main()
    {
       . . .
    }
    

    Usually this attribute is present by default. Check if the control works in a new simple Forms application.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.