
How to fix VB6 crash while Writing EXE
I recently ran into a problem where the VB5 SP5 IDE crashes while
Writing the .EXE file. That's after successfully finishing the compile
on an application that works perfectly when run inside the IDE.
It's not running out of memory or disk space resources, and happens on
a variety of machines running either NT4 SP5 or Win2K SP2. Every time
VB6 crashes with a Application Error that "The memory could not be
"written"."
In searching the newsgroups I found other people had hit this problem,
but no solution was posted, but I eventually found the answer in a VB
FAQ (Section 12.1).
In the IDE, arrays are dynamic by default. When compiled, arrays are
static by default. According to the FAQ this changes where the arrays
are stored (DGROUP instead of heap). Apparently, VB6 SP5 still has
problems that have been around for a very long time in how it handles
static arrays.
To fix it, you need to put the comment:
'DYNAMIC
as the first line the .frm source.
You could also manually use dynamic arrays and ReDim, but this is a
quicker change for existing code.
That forces all arrays to be dynamic, even when compiled. It fixed the
problem for me.
Good luck.