# Creating Compute Shaders throws E_INVALIDARG exception in SharpDX

I've recently been working on a small helper for creating and using compute shaders in C# along with Monogame/XNA. My end goal is simply to have compute shaders working in C#.

My main issue is as such:

   var result = SharpDX.D3DCompiler.ShaderBytecode.CompileFromFile(filepath, "CSMain", "cs_5_0", ShaderFlags.Debug);
if (result.ResultCode.Failure)
throw new Exception(\$"HLSL Compilation failed with the code: [{result.ResultCode.Code}] and message: [{result.Message}]");


Calling the constructor on the ComputeShader class throws the error: "HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect." (Of type SharpDXException). The device is obtained via Microsoft.Xna.Framework.Graphics.GraphicsDevice.Handle casted to a D3D11 Device.

Call Stack:

Anyone know how to fix this? Or is this just something I'll have to find some new way of doing?

NOTE:
The fact that I went down the Monogame-DirectX + SharpDX route is largely incidental, but I don't seem to have many options - something like Vortice.Windows, which aims to replace the now abandoned SharpDX, doesn't appear to have compute shader support. While I wouldn't mind using OpenGL, and would be happy with being recommended working .Net Core OpenGL binding libraries (Vulkan would probably be way over my head), that type of question isn't accepted here, but I'm aware it may be the better option.

The device from Microsoft.Xna.Framework is Direct3D 9, which isn't going to support Direct3D 11 features.