cudaD3D10RegisterResource fails with error "cudaErrorInvalidDevice"

Im trying to make use of the Direct3D 10 interoperability in CUDA 2.1 and

the following code generates an error when i try to bind a resource:

// Create vertex buffer

ID3D10Buffer *m_sectionVertexBuffer;

D3D10_BUFFER_DESC bd;

bd.Usage = D3D10_USAGE_DEFAULT;

bd.ByteWidth = sizeof( SimpleVertex ) * m_sectionMaxVerts;

bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;

bd.CPUAccessFlags = 0;

bd.MiscFlags = 0;

HRESULT hr = m_device->CreateBuffer( &bd, NULL, &m_sectionVertexBuffer );

cudaError_t err = cudaD3D10SetDirect3DDevice(m_device);

// err = cudaSuccess

err = cudaD3D10RegisterResource(m_sectionVertexBuffer,cudaD3D10RegisterFlagsNone);

// err = cudaErrorInvalidDevice

Not sure why it would be an invalid device since i create the buffer with the same device that i successfully bind to CUDA.

Or am i creating the buffer in such a way that it cannot be used by CUDA for some reason?

Edit: Nevermind, seems its working in release-mode so i guess the emulation mode doesnt cover interoperability stuff or something.