tags:

views:

59

answers:

1

I have a problem where Due to Shared memory, when MS Visual C 6.0 DLL crashes it also causes VB 6 EXE to crash. Our main program EXE is written in VB 6. It calls plug-ins (DLL's) for the various file types, these are written in MS Visual C 6.0. When a "C" plug-in (DLL) encounters a problem it some times crashes and this causes the EXE program to also crash as they share the same address space. So, I am looking for a way the prevent the MS Visual C 6.0 DLL's from causing the VB 6 EXE from also crashing, when the DLL crashes.

+1  A: 

It has nothing to do with DLLs vs EXEs. It is a thread that crashes. If you don't catch the exception then that will invoke the default exception handler in Windows. Which will terminate the process, optionally telling Microsoft about the problem.

Catching and handling exceptions like AccessViolation is not possible in VB6. It isn't worth the trouble anyway, your main execution thread has suffered a heart attack and cannot continue in a meaningful way. Even if you could catch it, the program is in a very poor state with its global state partially mutated. Trying to continue will just create more crashes. Or much worse, generate invalid results and destroy valuable data.

One option is to run the DLL in a separate process. A crash will terminate that process, not yours. Getting this right is very difficult, it is hard to detect the crash. And the process interop is tricky.

Hans Passant