Could not instantiate ActiveX control 'c932ba85-4374-101b-a56c-00aa003668dc' because the current thread is not in a single-threaded apartment

Hi,

I have a .NET .DLL called by a VB6 EXE. The following error message is when trying to instantiate a form in the .NET .DLL:

Could not instantiate ActiveX control 'c932ba85-4374-101b-a56c-00aa003668dc' because the current thread is not in a single-threaded apartment

Some documents suggest adding <STAThread()> proceeding the Main() method to enforce the .NET in running in the static thread. However, there is no Main() method in the .NET .DLL.

Any one knows how to solve this problem  Appreciated very much.


Answer this question

Could not instantiate ActiveX control 'c932ba85-4374-101b-a56c-00aa003668dc' because the current thread is not in a single-threaded apartment

  • Ridiculous

    Thanks for your helps. 

    My .NET .DLL doesn't have a Main() function. I replaced all the non .NET controls with .NET controls, and this error doesn't come up any more. 

    However, when the VB6 Active EXE calls this .NET DLL to show a form (the form is in the .NET DLL), this form shows up but it's blank, none of the controls and lables appears. I clicked on the form, and it became no response. Anyone knows why this happens  I am really puzzled. Thanks,

  • samur

    Hello,
    I had a similar problem.
    I solved it by doing the following:
    You need to add the following attribute <STAThread>_ (i.e. in VB) or [STAThread] in c# in before your main() method. There are cases when this alone doesnt work. In order to see if your thread is in the STAMode in the main, you can do

    MsgBox(Threading.Thread.CurrentThread.ApartmentState)
    if the STATE is not STA then you also need to add the following:
           
    Threading.Thread.CurrentThread.ApartmentState = Threading.ApartmentState.STA

    I guess it will work by then. If it doesnt try adding the message boxes to find out where exactly your thread goes in MTA. Ideally you shouldnt need to do this since there has to be only one entry point viz the MAIN.

    I hope this helps

  • richdenis

    if your dll use an ActiveX control, then your application(the startup, <startup.exe>)'  Main mehthod youd be attribute wit the STA. this the Method that you normally , or calling other method to invoke Application.Run(new Form1())
  • Could not instantiate ActiveX control 'c932ba85-4374-101b-a56c-00aa003668dc' because the current thread is not in a single-threaded apartment