Hi,
I have the following test fixture.
Code:
Imports System.Windows.Controls
Imports NUnit.Framework
<TestFixture>
Public Class SearchResultPaserTests
<Test>
<STAThread>
Public Sub ParseMethodReturnsComboBoxItem()
Dim srp As New SearchResultPaser
Assert.AreEqual(GetType(ComboBoxItem), srp.Parse(New SearchResult()).GetType())
End Sub
End Class
Which tests the following class which is in a class library referenced by a WPF application.
Code:
Imports System.Windows.Controls
Public Class SearchResultPaser
<STAThread>
Public Function Parse(result As SearchResult) As ComboBoxItem
[h] Return New ComboBoxItem()[/h]
End Function
End Class
I am getting a "Invalid Operation Exception : The calling thread must be STA, because many UI components require this." when I try to return a new ComboBoxItem . After reading
this post I tried adding the <STAThread> attributes but still no joy.
The SearchResultPaser class works fine when called form my WPF app presumably because it is then running on WPF's UI thread.
What can I do to resolve this.
Thanks