* FAQ    * Search  * Register * Login 
Active topics
Unanswered topics

All times are UTC-06:00



Post new topic  Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Visual Studio .Net Debugging... DOH... Not fun at times...
PostPosted: Mon Jul 17, 2006 10:37 pm 
Offline
DBB Fleet Admiral
DBB Fleet Admiral
User avatar

Joined: Thu Nov 05, 1998 12:01 pm
Posts: 2700
Website: http://home.swbell.net/wa5czn/index1.html
Location: Oklahoma City, Oklahoma, United States of America
Have a commercial grade program that I've written that uses 2 different 3rd party DLL's built into it.

One of the calls to one of the DLL libraries \"seemed\" to have a problem with a \"system.drawing.dll\"...

Message box had this information in it:

---
- An unhandled exception of type 'System.ArgumentException' occurred in
- system.drawing.dll
-
- Additional information: Invalid parameter used.
-
- [Break] [Continue] <Ignore> [Help]
---

*** Note *** Ignore button disabled above.

5 different message boxes most relating to system.drawing.dll would randomly occur.

... \"Try... End Try\" was not able to trap the error... DOH!... looked further into the problem...

... The \"real\" problem was a timing issue on the child form that was used by the main form.

What happened was the main form was attempting to update the child form before the initialization of that form was complete.

Just thought this \"experience\" might be helpful to someone trying to track down a Visual Studio .Net bug.

Happy Programming to you all!

:)


Top
   
 Post subject:
PostPosted: Mon Jul 17, 2006 10:40 pm 
Offline
DBB Alumni
DBB Alumni
User avatar

Joined: Wed Mar 15, 2000 3:01 am
Posts: 8826
Location: Seattle
Right now I'm actually wrangling with event timing issues myself. I'm writing a 3D engine using Managed DirectX and I need to figure out exactly when things get disposed so I don't try and render to a window that doesn't exist anymore.

I love .NET but sometimes the (lack of) documentation makes me want to cry.


Top
   
 Post subject:
PostPosted: Tue Jul 18, 2006 1:55 pm 
Offline
DBB Fleet Admiral
DBB Fleet Admiral
User avatar

Joined: Thu Nov 05, 1998 12:01 pm
Posts: 2700
Website: http://home.swbell.net/wa5czn/index1.html
Location: Oklahoma City, Oklahoma, United States of America
D,

Here's an idea...

- Create a boolean (true / false) flag defaulted as \"false\" when the program loads. (Call it \"ItemLoaded\")

- Set \"ItemLoaded = True\" when the item is there.

- Set \"ItemLoaded = False\" when the item is about to be disposed.

Perhaps that might help.

Happy Coding,
SirWinner


Top
   
 Post subject:
PostPosted: Tue Jul 18, 2006 9:39 pm 
Offline
DBB Alumni
DBB Alumni
User avatar

Joined: Wed Mar 15, 2000 3:01 am
Posts: 8826
Location: Seattle
Well, I essentially wound up doing that, but using the Device.Disposed property to determine if I should bail out of my loop.

The bad thing about using Managed DirectX is that it wants to use System.Windows.Forms for everything, which would be great if System.Windows.Forms didn't require you to use Application.DoEvents() to process the message pump. Combine that with the lack of a PeekMessage() equivalent and you're running in a tight loop that calls Render and then DoEvents, preventing the garbage collector from running and therefore bloating your program's RAM usage, not to mention using 100% of your time slice and thus 100% CPU usage (or in my case 50% on a P4 with HyperThreading, and limited to that because WinForms requires your application to be [STAThread]. GRR!)


Top
   
 Post subject:
PostPosted: Wed Jul 19, 2006 5:34 pm 
Offline
DBB Fleet Admiral
DBB Fleet Admiral
User avatar

Joined: Thu Nov 05, 1998 12:01 pm
Posts: 2700
Website: http://home.swbell.net/wa5czn/index1.html
Location: Oklahoma City, Oklahoma, United States of America
D,

I hear that!

Here's what we did to fix the \"system.drawing.dll\" issues in our program.

---
Dim frmABC As frmABC

frmABC = New ABC(Parm1,Parm2,Parm3)
frmABC.ShowDialog()

frmABC.Dispose() ' <-- This resolved the issue!
---

Otherwise, we'd see random \"system.drawing.dll\" error message boxes and occasionally GDI+ error messages while the running and exiting to windows!

*** Lesson learned: If the form is NOT disposed of properly during the normal running of the program, it will complain when program is exiting to windows!

---

Literally ONE week of programming time spent tracking down and fixing this \"bug\"!

---

Side point: Take code samples from someone and finely test them for issues like this and others before releasing your \"application\" for the \"Real World(tm)\" to use.

:oops:


Top
   
 Post subject:
PostPosted: Wed Jul 19, 2006 8:36 pm 
Offline
DBB Alumni
DBB Alumni
User avatar

Joined: Wed Mar 15, 2000 3:01 am
Posts: 8826
Location: Seattle
SW,

Got my app working like this (C# pseudocode):

Code:
class FOCUSApplication
{
  Form mainForm;
  Device device;

  public static void Main()
  {
    using(FOCUSApplication app = new FOCUSApplication())
    {
      Application.Run();
    }
  }

  public FOCUSApplication()
  {
    Application.OnIdle += new EventHandler(Application_Idle);

    mainForm = new Form();
    //set up mainForm
    mainForm.Closed += new EventHandler(mainForm_Closed);
    mainForm.Disposed += new EventHandler(mainForm_Disposed);
    mainForm.Show();

    // create DirectX device
    device.Disposing += new EventHandler(device_Disposing);
  }

  private void Application_Idle()
  {
    // raise custom Update event
    // that subsystems will handle
  }

  private void mainForm_Closed(object o, EventArgs e)
  {
    mainForm.Dispose();
  }

  private void mainForm_Disposed(object o, EventArgs e)
  {
    device.Dispose();
  }

  private void device_Disposing(object o, EventArgs e)
  {
    Application.Exit();
  }
}


All the benefits of managed code, without taking up 100% CPU. A bit convoluted but it works flawlessly. :D


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Descent'rs have piloted these pages
 
The layout and contents contained within this site are © DescentBB.net 1997-2006.
Descent, Descent II are © Parallax Software Corporation.
Descent III is Outrage Entertainment.
Descent is a Trademark of Interplay Productions.

Miner Wars™ is trademark of Keen Software House s. r. o.
.


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group