I’m developing for Windows Phone 7, and I’ve run into a bit of an issue when using Guide.BeginShowMessageBox and Guide.BeginShowKeyboardInput. Once the messagebox appears, the application will sometimes crash with the error:
“Both a vertex shader and pixel shader must be set on the device before any draw operations may be performed.”
The strange thing is, it seems like it’s crashing while the message box is visible, but I have the following check before my update and draw methods in my Game class:
protected override void Update(GameTime gameTime) {
if (IsActive && !Guide.IsVisible) {
//Update stuff here
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime) {
if (IsActive && !Guide.IsVisible) {
//Draw stuff here
}
base.Draw(gameTime);
}
The error definitely seems to be happening inside my //Draw stuff here method though. And it doesn’t seem to be every time. Only after about the fourth message box does it occur.
Is there a way to tell before drawing whether the vertex shader or pixel shader are not set? I’m using a BasicEffect object to do drawing.
Reapplying the BasicEffect at the beginning of the Draw call manually before doing anything else seems to fix the problem.