.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

APPCRASH error when exiting RealDWG WinForms App

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
eric.mills
1030 Views, 4 Replies

APPCRASH error when exiting RealDWG WinForms App

I have developed a C# winforms app with RealDWG SDK. When I close my form I get the "App has stopped working" error below.

 

I've added in some Dispose methods to see if that was the issue, but I still get the error.

I added a dispose method to my HostApplication class and I called my Winform dispose method.

I thought that the error was caused by unfinished RealDWG business at the Form Closing event.

 

I am using RealDWG 2013, Visual Studio 2010 SP1, Windows 7 64-bit.

I also have AutoCAD 2012 and 2013 installed.

I know that AutoCAD and RealDWG both use acdb19.dll.

 

My app contains 6 classes with around 1000 lines of code on each class, so to paste in my code would be impossible. Here is my code structure.

 

I start by implementing a HostApplicationService Class (MyHost.cs)

Then I call my Windows Form. (MainForm.cs)

From my form I collect object data from a SqlDatabase.

Once the data is aquired, I send the data to a Class that handles my AutoCAD classes. (AutoCAD.cs)

In this class I create my RealDWG Database.

Next I pass the database to various IDisposable classes that perform AutoCAD actions.

I.E, CreateTitleBlock() CreateLayers(), DrawShape(); etc..

 

Everything works great, except when I go to close the app, I get the error.

I dispose everything I can think of right before exiting.

 

I've tried

this.Close();

Application.Exit();

 

Any ideas on how to dispose the app or close it cleanly?

 

Thanks,

Eric

 

Here is the error....

 

Problem signature:

  Problem Event Name: APPCRASH

  Application Name: LongBayRD.exe

  Application Version: 1.0.0.0

  Application Timestamp: 519fa185

  Fault Module Name: acdb19.dll

  Fault Module Version: 19.0.55.0

Fault Module Timestamp: 4f309c70

  Exception Code: c0000005

  Exception Offset: 0000000000058166

 

4 REPLIES 4
Message 2 of 5

There's really no way to tell you what the problem may be without seeing the code. It could be a missing call to Dispose() on something, or possibly multiple calls to Dispose() that might have to occur in a certain order, but without the code, anything is just a wild guess.
Message 3 of 5
eric.mills
in reply to: eric.mills

I really appreciate the response, I figured it out.

 

// app form closing event

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)

{

    MyHost.WorkingDatabase = null;

    MyHost.Current.Dispose();  

    Application.Exit();

}

 

// constructor for HostApplicationServices class

public MyHost()

{

    RuntimeSystem.Initialize(this, 1033);

}

 

// dispose method for HostApplicationServices class

void IDisposable.Dispose()

{

    this.Dispose();

    RuntimeSystem.Terminate();  // added this to fix it

}

 

Simple RealDWG 101 Rules.

I guess I failed to mention that this is my first RealDWG project.

See attached for the complete MyHost class.

There may be better ways to shut down the RuntimeSystem but for now this is the technique I plan to use.

 

Message 4 of 5


@EriCSharp wrote:

 

// dispose method for HostApplicationServices class

void IDisposable.Dispose()

{

    this.Dispose();

    RuntimeSystem.Terminate();  // added this to fix it

}

 

 


You're deriving from a class that already implements IDisposable, and provides a virtual overridable Dispose( bool ) method that you can override to get control when the instance is disposed. You shouldn't implement IDisposable again on your class, you should instead override the Dispose( bool ) method of the base class (DisposableWrapper), and do your cleanup in that, and then call base.Dispose( bool ) to let the base class do its thing.

 

 

 

Message 5 of 5
eric.mills
in reply to: eric.mills

Yes, I see ..... thanks DiningPhilosopher

 

protected override void Dispose(bool value)

{

    RuntimeSystem.Terminate();

}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost