A
angshuman.agarwal
Hi,
I have a ["custom"] owner drawn combo box ["control"] (using .Net 2.0
Framework). I have written the Nunit test for the same. I am setting
the AutoCompleteSource Property (AutoCompleteSource.CustomSource) and
AutoCompleteMode Property (AutoCompleteMode.Append) for the Combo at
runtime and also have hidden these properties [Browsable(false)] at
design time.
Now, when I am testing the function where I am setting
AutoCompleteSource & AutoCompleteMode values, the Nunit test Fails
with the following error message.
------------------------------------------------------------------------------------------------------------------------------------------------
System.Threading.ThreadStateException: Current thread must be set to
single thread apartment (STA) mode before OLE calls can be made. Ensure
that your Main function has STAThreadAttribute marked on it.
at
System.Windows.Forms.ComboBox.set_AutoCompleteSource(AutoCompleteSource
value)
------------------------------------------------------------------------------------------------------------------------------------------------
Presently, what is possible is to catch the exception in a try...catch
block and if the ThreadStateException is thrown , I am logging it in a
file. I am still finding a solution to the problem. Presently, I have
just supressed the problem !
NOTE: This happens only when I run NUnit. But if I just run my
executable (when tests dont run) there are no issues.
Any Inputs ?
Thx In Advance
Angshuman Agarwal
I have a ["custom"] owner drawn combo box ["control"] (using .Net 2.0
Framework). I have written the Nunit test for the same. I am setting
the AutoCompleteSource Property (AutoCompleteSource.CustomSource) and
AutoCompleteMode Property (AutoCompleteMode.Append) for the Combo at
runtime and also have hidden these properties [Browsable(false)] at
design time.
Now, when I am testing the function where I am setting
AutoCompleteSource & AutoCompleteMode values, the Nunit test Fails
with the following error message.
------------------------------------------------------------------------------------------------------------------------------------------------
System.Threading.ThreadStateException: Current thread must be set to
single thread apartment (STA) mode before OLE calls can be made. Ensure
that your Main function has STAThreadAttribute marked on it.
at
System.Windows.Forms.ComboBox.set_AutoCompleteSource(AutoCompleteSource
value)
------------------------------------------------------------------------------------------------------------------------------------------------
Presently, what is possible is to catch the exception in a try...catch
block and if the ThreadStateException is thrown , I am logging it in a
file. I am still finding a solution to the problem. Presently, I have
just supressed the problem !
NOTE: This happens only when I run NUnit. But if I just run my
executable (when tests dont run) there are no issues.
Any Inputs ?
Thx In Advance
Angshuman Agarwal