Search code examples
c++directxwindows-8.1windows-10toolkit

Win8 app crash on Win10 (D3D11CreateDevice return null)


I have a Xamarin Forms-app writen in C# and using DirectX Tool Kit with interop calls to C++.

The app is an Windows 8.1 app and run great on Windows 8.1 and has runed on my Windows 10 computer.

But one day I started Visual Studio 2015 and was going to run the app on Windows 10. It just crash from no where. I think Windows 10 update can be the problem?

Anyway, here is some code from 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 seems to return null (device and context) And crash in device.As(&m_d3dDevice) and the error message says that some SDK Component may be missing.

Anyone who know what the problem can be? Is there any DirectX SDK i must install? Why could I run the app Before?

Thanks!


Solution

  • From DirectX TK: 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.