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

后端 未结 3 1168
耶瑟儿~
耶瑟儿~ 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:41

    Have you tried this?


    ... simply create an app.config file for the dll you are attempting to test, and add some NUnit appropriate settings to force NUnit to create the test environemnt as STA instead of MTA.

    For convenience sake, here is the config file you would need (or add these sections to your existing config file):

    
    
        
            
                

提交回复
热议问题