Win8 应用程序在 Win10 上崩溃(D3D11CreateDevice return null)

Win8 app crash on Win10 (D3D11CreateDevice return null)

我有一个用 C# 编写的 Xamarin Forms 应用程序,并使用 DirectX 工具包和对 C++ 的互操作调用。

该应用程序是 Windows 8.1 应用程序,运行 在 Windows 8.1 上非常好,并且已在我的 Windows 10 计算机上 运行ed。

但有一天我开始 Visual Studio 2015 年,打算在 Windows 10 上 运行 应用程序。它突然崩溃了。我觉得Windows10更新会不会有问题?

无论如何,这里是 Windows8.1 的 DirectX 工具包中的一些代码:

ThrowIfFailed(
    D3D11CreateDevice(
    nullptr,                    // Specify null to use the default adapter.
    D3D_DRIVER_TYPE_HARDWARE,
    0,
    creationFlags,              // Optionally set debug and Direct2D compatibility flags.
    featureLevels,              // List of feature levels this app can support.
    ARRAYSIZE(featureLevels),
    D3D11_SDK_VERSION,          // Always set this to D3D11_SDK_VERSION for Windows Store apps.
    &device,                    // Returns the Direct3D device created.
    NULL,                       // Returns feature level of device created.
    &context                    // Returns the device immediate context.
    )
    );

// Get D3D11.1 device
ThrowIfFailed(
    device.As(&m_d3dDevice)
    );

D3D11CreateDevice 似乎 return null(设备和上下文) 并在 device.As(&m_d3dDevice) 中崩溃,错误消息显示某些 SDK 组件可能丢失。

有人知道问题出在哪里吗?我必须安装任何 DirectX SDK 吗?为什么我可以 运行 以前的应用程序?

谢谢!

从 DirectX 到: http://directxtk.codeplex.com/workitem/1317

This is because your creationFlags are D3D11_CREATE_DEVICE_DEBUG which will fail if you do not have the Direct3D debug device installed--it's only on developer machines.

Since you are on Windows 10, likely you were upgraded from one build to another which disables the debug device because it's outdated. You need to re-enable it.