Visual Studio 2017 年的 Microsoft DirectX Sound

Microsoft DirectX Sound on Visual Studio 2017

我有一个用 Visual C# 2010 制作的旧程序。现在我想再次使用它,所以我尝试在 Visual 2017 Community 上编译,但它在 MicrosoftDirectSound 上启动了一个异常。我知道这是因为它是 32 位的所以我会问你是否有任何解决方法来实现该 directx 或者我必须在新场景中使用什么。我也尝试过 "corflags",但它 returns 是关于强命名签名的警告。

System.BadImageFormatException: ... is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Microsoft.DirectX.DirectSound 是遗留 Managed DirectX 1.1 程序集的一部分。它们仅支持 .NET 1.1 和 .NET 2.0 运行时,而不支持现代 .NET 4.x 运行时。您还注意到必须强制使用 /platform:x86.

您最好的选择是使用 SlimDX which is intended as a drop-in replacement for the Managed DirectX 1.1 assemblies including x64 support. A more modern solution is SharpDX,但当然您可能无论如何都不应该在新应用程序中使用 DirectSound。

DirectX and .NET

The other thing to keep in mind is that the legacy DirectX Managed DirectX 1.1 assemblies are only installed by the legacy DirectX SDK or the deprecated DirectX End-User Runtime Redistribution Package on systems with the .NET 2.0/3.x Runtime enabled. See Not So DirectSetup and DXSETUP Update.