Well, it seems to be a problem with the Z-buffer.

Debug Output: Direct3D9: (ERROR) epthStencil Buffer must be at least as big as the RenderTarget. Process Sandbox.exe (3160)
Also I don't need to call Device.BeginScene() and Device.EndScene().

When I maximize the screen everything is OK.
When I restore it to its normal size, I get this error.