AnsweredAssumed Answered

.NET memory error on closing ArcMap with open control form

Question asked by kdolson on Mar 26, 2012
Latest reply on Nov 5, 2012 by marknguyen
I am developing a custom set of tools for ArcMap implementing BaseToolBar and BaseCommand in VB.NET.  For non-admin users, whenever the ArcMap application is closed with one of the tool's modeless forms still open, the following .NET error message appears:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Research into this issue has suggested that my COM objects are not being disposed of properly before the application shuts down.  Following the advise here: http://edndoc.esri.com/arcobjects/9.2/NET/fe9f7423-2100-4c70-8bd6-f4f16d5ce8c0.htm#AOShutdown,
I added an AOUninitialize.Shutdown command at the form's Disposed event, but this did not make any difference.

One of my forms is a simple "About" dialog that only shows version info and does nothing else.  This form references no ArcObjects other than the fact that you open it from a BaseCommand button.  So, there are no specific COM objects that need to be released or anything.

One thing that will prevent this error from occurring is to open the form as modal.  But I've seen and used other custom tools with modeless dialogs that do not have this issue.

Any advice/suggestions would be greatly appreciated.

Outcomes