MSTest setting Apartment Threading to MTA

北城以北 提交于 2019-12-10 13:31:02

问题


I'm using MSTest in Visual Studio 2010 on a project that needs the apartment threading model set to MTA.

I've looked online and the items I've found and tried seem to only work with Visual Studio 2008 and 2005, see http://blogs.msdn.com/b/ploeh/archive/2007/10/21/runningmstestinanmta.aspx.

Thanks


回答1:


You're right, most of the information online is out of date.

I eventually found Microsoft's documentation: How to: Run Unit Tests in MTA mode

You need to open your .testsettings file in an XML editor and add the following:

<TestSettings>
  <Execution>
    <!-- ... -->
    <ExecutionThread apartmentState="MTA" />
  </Execution>
</TestSettings>

Then restart Visual Studio. This worked for me.



来源:https://stackoverflow.com/questions/4730498/mstest-setting-apartment-threading-to-mta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!