It's difficult to know what is the problem when you show only one line of code. Please show what "createDeviceFlags" and "featureLevels" have. Also, make sure to disable FPU exceptions.
Also, why not trying something that already implements all this and then just adapting it to your needs?
PXL provides Direct3D 11 implementation, you can use it as a reference.