Thanks. I solve the problem by this method, too.
But this address the symptoms, not the cause.
I'm a rookie of DirectX develop, so I spend few hours to find bug.
The program always stop at this line:
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Black, 1.0f, 0);
Or all objects about "device". And cause errors:
A first chance exception of type 'Microsoft.DirectX.Direct3D.InvalidDataException' occurred in Microsoft.DirectX.Direct3DX.dll
A first chance exception of type 'Microsoft.DirectX.Direct3D.InvalidCallException' occurred in Microsoft.DirectX.Direct3D.dll
So anyone can solve it?