Build/Test Issues

How can I force NCrunch to run tests in STA?

Started by borysl on 6,372 views

I get this error System.InvalidOperationException : The calling thread must be STA, because many UI components require this.
on show component

I know what this problem is and thus in my NUnit tests I use this configuration:
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>

<NUnit>
<TestRunner>
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>

However looks like NCrunch ignores NUnit configuration and runs anyway in MTA.

I got this error before when I use Resharper. The solution was add [STAThread] to the test method.

Post a reply

Log in to reply.