I saw "Microsoft C++ exception: long at memory location" at this line :
pDev->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, m_Size * m_Size, 0, m_TriangleCount);
pDev is LPDIRECT3DDEVICE9 and I used DirectX 9.0.
I don't know what 'long at memory location' means exactly.
Why the message is printed at this line?
You should ignore any "first chance exception" message that you see in the Output window, that just shows exceptions being used internally in the DirectX plumbing to deal with error conditions. An exception is only fatal when it doesn't get caught.
What you should never ignore is the return value of DrawIndexedPrimitive(). It returns an HRESULT, a status code that indicates whether or not the function call succeeded. The rough code ought to look like this:
HRESULT hr = pDev->DrawIndexedPrimitive(...);
if (FAILED(hr)) {
// Report error code stored in "hr" and terminate
//...
}