views:

76

answers:

1

We have an Windows Forms application which make use of some com components such as the web browser control and an API for a signature pad.

When the application is closed, sometimes an error dialog is shown with the following text:

"sw: myapp.exe - Error in Application"

The text was like this: The instruction xyz caused an illegal access at address yxz when performing the following operation: READ.

The strange thing is, even I activated unmanaged debugging in visual studio and switched exceptions on, the debugger doesn't break.

After that, the application cannot be restarted from visual studio, because it says that files are still in use as if the application is still running. When I try to attach the debugger to this process it fails.

Does anybody know how to debug such a strange behavior? What does SW in the error dialog title mean? I searched for it on my system, it is apparently no existing dll.

+1  A: 

you may not be unloading your COM objects correctly.

var myObj = ISomeCOMObject.MyObject();
myObj.DoStuff();
myObj.Dispose();

//the important line of code that you need
Marshal.ReleaseComObject(myObj);

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject%28v=VS.100%29.aspx

Derick Bailey