c++ - Win10 上的 Win8 应用程序崩溃(D3D11CreateDevice 返回 null)

标签 c++ directx windows-8.1 windows-10 toolkit

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

该应用程序是一款 Windows 8.1 应用程序,在 Windows 8.1 上运行良好,并已在我的 Windows 10 计算机上运行。

但有一天我启动了 Visual Studio 2015 并打算在 Windows 10 上运行该应用程序。它突然崩溃了。我认为 Windows 10 更新可能是问题所在?

无论如何,这里有一些来自 DirectX Tool Kit for Windows8.1 的代码:

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 似乎返回 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.

关于c++ - Win10 上的 Win8 应用程序崩溃(D3D11CreateDevice 返回 null),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35481846/

相关文章:

c++ - 如何使用 boost::beast 检测 websocket 中的断开连接?

c# - 为什么我会收到不明确的错误

c++ - 解决模板类之间的循环依赖

java - C++ 到 Java 除法运算符

c++ - 放置-新地址对齐

css - Windows 8.1 中的 chrome 是否停止支持某些字体?

windows - 切换到cmd模式后切换回PowerShell模式

directx - 处理 Minecraft 风格地形中的方 block (d3d/c++)

c++ - 将自定义矩阵转换为 float *

c# - DirectX 桌面