【发布时间】:2019-09-20 13:55:38
【问题描述】:
我正在尝试使用在 Unity 中运行的 CSCore (https://github.com/filoe/cscore) 获取默认音频端点,我收到了 System.NotSupportedException。我正在使用 Unity NUnit 测试框架对此进行测试。奇怪的是,在编辑器中运行代码时,它可以工作,但构建会收到此异常。有人可以解释为什么会这样吗?
我正在做的构建是 x64,我检查了我正在使用的 DLL 是为 x86 和 x64 构建的。我正在使用 1.2.0 Release DLL。下面提供了测试代码和异常堆栈跟踪:
[Test]
public void GetAudioEndpoint_Default_NoException()
{
Assert.DoesNotThrow(delegate ()
{
var deviceEnumerator = new MMDeviceEnumerator();
var device = deviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
});
}
GetAudioEndpoint_Default_NoException (0.039s)
---
Expected: No Exception to be thrown
But was: <System.NotSupportedException: Specified method is not supported.
at (wrapper cominterop) CSCore.CoreAudioAPI.MMDeviceEnumerator+MMDeviceEnumeratorObject..ctor()
at CSCore.CoreAudioAPI.MMDeviceEnumerator.CreateMmDeviceEnumerator () [0x00000] in <b6880cc671004d3aa0cc66420dbddb79>:0
at CSCore.CoreAudioAPI.MMDeviceEnumerator..ctor () [0x00000] in <b6880cc671004d3aa0cc66420dbddb79>:0
at CSCore.Tests.DeviceTests+<>c.<GetAudioEndpoint_Default_NoException>b__0_0 () [0x00001] in ***\DeviceTests.cs:13
at NUnit.Framework.Constraints.ThrowsConstraint+VoidInvocationDescriptor.Invoke () [0x00001] in <59819be142c34115ade688f6962021f1>:0
at NUnit.Framework.Constraints.ThrowsConstraint+ExceptionInterceptor.Intercept (System.Object invocation) [0x0000a] in <59819be142c34115ade688f6962021f1>:0 >
---
at CSCore.Tests.DeviceTests.GetAudioEndpoint_Default_NoException () [0x00001] in ***\DeviceTests.cs:11
【问题讨论】: