Jump to content
  • Advertisement
Sign in to follow this  
plusnoir

Win forms in XNA, exception even with [STAThread]

This topic is 2512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[color=#333333]I am attempting to use System.Windows.Forms objects within an XNA application (as opposed to using a XNA device in a System.Windows.Forms application) - which has no examples as far as the AppHub samples go.
[color=#333333]When I attempted to resize the window I got an exception indicating that the thread was not a STA thread; so I updated my Main method as follows:

[STAThread] // Added this
static void Main(string[] args)
{
using (Game1 game = new Game1())
{
game.Run();
}
}



[color=#333333]After I fixed this problem; as soon as I draw some models (using the 'X' format) into the XNA window and try to resize, another exception occurs.


[color=#444444]An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Xna.Framework.Game.dll Additional information:

[color=#444444]A previous Draw call threw an unhandled exception. See InnerException for details.
[/quote]

Any idea how i could handle this?
Thanks in advance,
noir

Share this post


Link to post
Share on other sites
Advertisement

[color=#333333]I am attempting to use System.Windows.Forms objects within an XNA application (as opposed to using a XNA device in a System.Windows.Forms application) - which has no examples as far as the AppHub samples go.

Because you're not supposed to do it that way.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!