NUnit 测试无法识别 gcAllowVeryLargeObjects 设置

Bra*_*son 5 .net c# nunit out-of-memory

我正在使用 NUnit 3.12、VS 2019 和 .Net 4.6.1。

我试图<gcAllowVeryLargeObjects enabled="true"\>通过 App.config 设置 NUnit 测试的设置,但在实际执行测试时它似乎没有注册配置更改。

这是我的测试项目的 App.config:

<configuration>
  <runtime>
    <gcAllowVeryLargeObjects enabled="true" />
  </runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)

失败的代码:

[Test]
public void TestLargeAllocation()
{
    var x = new double[18000, 18000];
}
Run Code Online (Sandbox Code Playgroud)

System.OutOfMemoryException 消息:“数组维度超出了支持的范围。”

我已经验证输出目录中的tests.dll.config实际上包含配置设置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <gcAllowVeryLargeObjects enabled="true" />
    <assemblyBinding xmlns=...
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激。