Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.NET application with Accpac ocx created Memory could not be read erro

Status
Not open for further replies.

vbdbcoder

Programmer
Nov 23, 2006
247
US
I have written a .NET 4.0 application (in C#) using OE1100.OCX. On my .NET main Form, I placed an OE1100.ocx. On the OE1100.ocx, I added a few more extra buttons (.NET buttons) to perform extra business functions, by launching extra .NET screens.

Things are all good except when the main form is closed. When the main form is closed, I keep getting the error message box pop, which saying “The memory could not be read”. It ONLY happens from the exe. The debug mode stepping through the code did not produce any error.

I have searched on internet for solution and can't seem to find one. How to prevent the error messagebox from poping up?

Thanks.

 
You could try programatically clicking the close button on the OCX before you close your form down.
 
Thanks for the feedback. I think I should share the solution.

The source of the problem is .NET has released all the resource (managed resource) when the form is closed. Yet, the Accpac OCX (unmanaged resource) has not truely released by the form_close() event. Accpac OCX stays in memory due to it is a VB6 ocx, plus the other DLLs it depends on, e.g. Kernal, User32, Msvbvm6... just to name a few.

Below is solution in code in a rough format:

OE1100_OnUIAppClosed(object sender, EventArgs e)
{
this.Dispose(false); // do not dispose the managed resources
Process.GetCurrentProcess().Kill(); //ARGHlglglgl.... brutally kill myself... required System.Diagnostics namespace
}

Form_Closing()
{
if (OE1100.UIAppIsOpen == true)
{
OE1100.CloseUIApp();
}
}

Form_Closed()
{
this.Dispose(false); // do not dispose the managed resources
Process.GetCurrentProcess().Kill(); //ARGHlglglgl.... brutally kill myself...
}

.NET should work... upgrade VB6 app to .NET....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top