Question

I just updated to Visual Studio 2013, ReSharper 8.0.2 and mspec to the latest version.

It was working fine running all the unit tests that some of the tests are creating UI controls that needs to be STAThread. Don't ask me why some of the tests are like that and can it not be separated. I wish if it was not too late for the game. I don't know what could cause for the Threads to be MTA this time when I updated.

I can easily quick fix this issue to pass the tests by putting a check on EACH call if it is STA and if not just do nothing, but that doesn't work some of the tests required the thread to be STA. I also tried adding [STAThread] on the method called but still no lack.

MSpec said they don't have a similar attribute like NUnit [RequiresSTA]. I am not sure if it was MSpec or ReSharpers thread that caused this to become MTA.

EDIT: Similar but the answer did not solve the problem

Why do I get an Invalid Operation Exception (non STA thread?) running this MSpec test on TeamCity?

EDIT 2: Isolated the problem using the updated mspec libs and run the Unit Test in VS 2012, it works fine and the ApartmentState of the Thread is STAThread. So I'm now concluding it has something to do with ReSharper 8.x having its threadpool start threads in MTA. Anyone know how to config the ApartmentState?

Was it helpful?

Solution

This is as designed by MSpec and it was because ReSharper's Runner that changed.

More info can be found here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top