I haven't been able to figure this one out for NUnit yet. There was a similar question asked, here where this exception was being raised. The answer resolves usage with xUnit, and the asker reports that he got it working for MSTest. I have tried calling Dispatcher.CurrentDispatcher.InvokeShutdown();
in the [TearDown]
, [TestFixtureTearDown]
, and [Test]
methods, and am still getting the exception.
A few more details about my implementation: I've created an InputBox class which extends System.Windows.Window. I made a static method, InputBox.Show(prompt)
which executes the following code:
var input = "";
var t = new Thread(() =>
{
var inputBox = new InputBox(prompt);
inputBox.ShowDialog();
input = inputBox.Input;
}) {IsBackground = true};
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
return input;
Any ideas?