0

I came across this post here C# Which is the fastest way to take a screen shot? and am trying to implement the answer that utilizes SharpDX. It appears to run fine on Windows 10, however, it crashes on Windows 7. The error it gives is:

Unhandled Exception: SharpDX.SharpDXException: HRESULT: [0x800004002], Module: [General], 
ApiCode: [E_NOINTERFACE/No such interface supported], Message No such interface supported

And the stack trace it points to...

var factory = new Factory1();
var adapter = factory.GetAdapter1(0);
var device = new SharpDX.Direct3D11.Device(adapter);
var output = adapter.GetOutput(0);
var output1 = output.QueryInterface<Output1>();

Happens at output1 line where it does the QueryInterface. I don't know a whole lot about graphics drivers, but is this an issue with the DirectX11 configuration? Or is this something inherent to Windows 7?

Euthyphro
  • 135
  • 1
  • 9

1 Answers1

1

SharpDX is nothing more than a thin managed code wrapper around the native C/C++ COM interface for Direct3D. As such, all the information you need can be found in the Direct3D documentation on MSDN. I would highly recommend reading through whatever you can find there, as almost all of the restrictions and caveats apply to SharpDX.

Now, the code you have is doing the following:

1) Creating a DXGI 1.1 Factory interface (IDXGIFactory1).

2) Getting a DXGI 1.1 Adapter interface for the first graphics adapter (IDXGIAdapter1).

3) Creating a Direct3D 11 Device interface from the aforementioned adapter (ID3D11Device).

4) Getting the first output from the adapter interface (IDXGIOutput).

5) Querying for the DXGI 1.1 Output interface (IDXGIOutput1) from the DXGI 1.0 Output interface.

The last step of this process is the point where things fail. This is because the interface you're asking for (IDXGIOutput1) is not supported on standard Windows 7 - it requires Windows 8+ or Windows 7 with the Platform Update. You can see that in the Requirements portion of the IDXGIOutput1 documentation on MSDN.

Again, I would highly recommend you familiarize yourself with the C/C++ interfaces defined by Direct3D if you plan to do any further work with DirectX or SharpDX.

Alex
  • 1,794
  • 9
  • 20