Jump to content
  • Advertisement
Sign in to follow this  
Krisc

C#, Form problems with DirectX

This topic is 4970 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

I am not exactly sure where to put this but I am having trouble with my application. I am using a directx class I made and I have a running loop that continuosly draws to the screen. The problem is that in windowed mode, when the X button on the form is hit the application closes but I get an error in static void Main() that reads. "An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll Additional information: Cannot access a disposed object named "frmTesting"." I am not really sure how to go about fixing this. frmTesting.cs iDraw.cs iTesting.zip (whole project) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Try moving the Graphics setup out of the form load into it's own proc, then call like this...

static void Main()
{
// Show our form and Initialize Graphic Engine
using (Form1 frm = new Form1())
{
frm.Show();
frm.InitializeGraphics();
Application.Run(frm);
}
}

Also olny have the xxx.show() in the main call. not in the forms constructor.

(Have a look how the systems are set up in the SDK examples, try an follow them first, get you screens to load and run, then break them up into an engine form. I am starting to look at the sample framework that comes with the SDK, you might want to have a look at how that runs.)

Share this post


Link to post
Share on other sites
Thanks! This fixed it for me as well as separating the constructor and initializing function...


static void Main()
{
using(frmTesting app = new frmTesting())
{
app.Show();
app.Initialize();
//Application.Run(app);
}
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!