When you try to instantiate a windowsforms control in your NUnit test, you could get the following error:

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.

This has something to do with the fact that windows forms controls like to run in STA (Single threaded apartment) and the latests version of Nunit run as MTA (Multi Threaded apartment).

After some googling (which only returned a small number of hits), I found “Nunit and STATThread by frater”. The solution happens to be very simple. Add this to the assembly where you have the test and the error will go away.

```xml <configSections> <sectionGroup name=“NUnit”> <section name=“TestRunner” type=“System.Configuration.NameValueSectionHandler”/> </sectionGroup> </configSections>

<NUnit> <TestRunner> <add key=“ApartmentState” value=“STA” /> </TestRunner> </NUnit>``` So another day and another problem solved.