Bitmaps and threading model

  • Thread starter Thread starter WRH
  • Start date Start date
W

WRH

Hello
I have a Form where I display DirectX Direct3D stuff on one panel
and a WebBrowser in another. Compiles & runs fine until I add
one line...

private Bitmap bmpForm= new Bitmap(typeof(Form1), "frame5.bmp");

Compiles ok, but does not run... I get a System Thread Exception
where I instantiate the web browser...
"Could not instantiate ActiveX because the current thread is
not in a single-threaded apartment".

Does loading a Bitmap change the threading model? What should
I do to get my bitmap?
 
WRH,

I wouldn't create the bitmap in the declaration. Rather, try it when
the form loads, after the window and the webbrowser control is created.

Hope this helps.
 
That did the trick! Thanks.

Nicholas Paldino said:
WRH,

I wouldn't create the bitmap in the declaration. Rather, try it when
the form loads, after the window and the webbrowser control is created.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

WRH said:
Hello
I have a Form where I display DirectX Direct3D stuff on one panel
and a WebBrowser in another. Compiles & runs fine until I add
one line...

private Bitmap bmpForm= new Bitmap(typeof(Form1), "frame5.bmp");

Compiles ok, but does not run... I get a System Thread Exception
where I instantiate the web browser...
"Could not instantiate ActiveX because the current thread is
not in a single-threaded apartment".

Does loading a Bitmap change the threading model? What should
I do to get my bitmap?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top