Using WPF components in NUnit tests - how to use STA?

后端 未结 3 1263
耶瑟儿~
耶瑟儿~ 2021-02-02 06:16

I need to use some WPF components in an NUnit unit test. I run the test through ReSharper, and it fails with the following error when using the WPF object:

S

3条回答
  •  天命终不由人
    2021-02-02 06:45

    You should add the RequiresSTA attribut to your test class.

    [TestFixture, RequiresSTA]
    public class MyTestClass
    {
    }
    

提交回复
热议问题