问题描述
我们正在将WPF应用程序移植到.NET Core 3,预览版5。
一些NUnit测试需要在STA线程中运行。
We are in the process of porting a WPF app to .NET Core 3, preview 5.Some NUnit tests need to run in STA threads. How can this be done?
[STAThread],[RequiresSTA]等属性都没有作用。
这也行不通:[assembly:RequiresThread(ApartmentState.STA)]
None of the attributes like [STAThread], [RequiresSTA], ... work.This also doesn't work: [assembly: RequiresThread(ApartmentState.STA)]
.NET Core 3中似乎没有公开表观命名空间。
The Apparent namespace does not seem to be exposed in .NET Core 3.
有人这样做吗?
推荐答案
<$ c $在NUnit 3.12中首次为.NET Standard 2.0启用了c> ApartmentAttribute 。
首先更新NUnit框架的版本,然后使用 [Apartment(ApartmentState.STA)]
。
First update your version of the NUnit framework, then use [Apartment(ApartmentState.STA)]
.
这篇关于如何在STA线程中运行NUnit测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!