single-threaded apartment (STA); MbUnit-2.4.2.130; WebPanel;

140 views
Skip to first unread message

Tricky

unread,
Jun 26, 2008, 10:37:19 AM6/26/08
to MbUnit.Dev
Hi,

I am trying to make integration test of my application. One of the UI
control is the webbrowser, that has it's own thread for refreshing. It
means the main application is a STA, but the WebBrowser control is not
STA,
that causes the exception below. Are anyways to ignor multithreaded
controls? Thanks.
I.e. NUnit does not throw such exception.

Regards,
Tricky.

The error body:

TestCase 'Test_SubmitCaseDropWorkItem.TestSubmitCaseDropWorkItem'
failed: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot
be instantiated because the current thread is not in a single-threaded
apartment.
System.Threading.ThreadStateException
Message: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot
be instantiated because the current thread is not in a single-threaded
apartment.
Source: System.Windows.Forms
StackTrace:
at System.Windows.Forms.WebBrowserBase..ctor(String clsidString)
at System.Windows.Forms.WebBrowser..ctor()
at SmartClient.Controls.MinimalWebBrowser.InitializeComponent() in
C:\\SmartClient.Controls\WebBrowser\MinimalWebBrowser.Designer.vb:line
24
at SmartClient.Controls.MinimalWebBrowser..ctor() in C:
\SmartClient.Controls\WebBrowser\MinimalWebBrowser.vb:line 11
at
SmartClient.Dropzone.UI.CustomizedContentView.InitializeComponent() in
C:\SmartClient.Dropzone.UI\SubmitCaseDrop\Workitems\Drop\SmartParts
\CustomizedContentView.Designer.vb:line 25
at SmartClient.Dropzone.UI.CustomizedContentView..ctor() C:
\SmartClient.Controls\WebBrowser\MinimalWebBrowser.Designer.vb 24

Tricky

unread,
Jun 26, 2008, 12:00:05 PM6/26/08
to MbUnit.Dev
I am using the Framework 2.0

Jeff Brown

unread,
Jun 26, 2008, 4:34:27 PM6/26/08
to MbUn...@googlegroups.com
Add [TestFixture(ApartmentState=ApartmentState.STA)] to your test.

This is now the default in MbUnit v3.

Jeff.

Tricky

unread,
Jun 27, 2008, 4:50:00 AM6/27/08
to MbUnit.Dev
It says 'ApartmentState is not declared'. I added ApartmentState =
System.Threading.ApartmentState.STA.
It looks that there is no such attribute in the version 2.4. What do
you think? Thanks.

Jeff Brown

unread,
Jun 27, 2008, 7:31:48 AM6/27/08
to MbUn...@googlegroups.com
I think I might have mispelled it...
It's in there for sure.

Tricky

unread,
Jun 27, 2008, 9:19:03 AM6/27/08
to MbUnit.Dev
Thanks Jeff. It solved a problem.
Reply all
Reply to author
Forward
0 new messages