VB6 freezes when making exe file

4k Views Asked by At

I'm writing a project in VB6. I'm using Win7-32 bit and having problem with project, This project have writen many year's ago and now I'm recompiling that. When I issue Make xxx.exe command, VB6 starts compilation and freezes and also creates more than 10,000 *.tmp files, after minutes it closes IDE and nothing makes. Where is my mistake?

6

There are 6 best solutions below

0
On

What worked for my issue with VB6 freezing while compiling a large executable project, was to limit the CPU cores of the VB application to just one core (that is, the affinity mask set to 1 for the VB6 process).

Note that this works for me only if the VB6 process starts with affinity mask set to 1, not just by enforcing the affinity mask (in task manager) after the VB process has started. To start VB6 with affinity mask set to 1, use the following shortcut (for 64 & 32 bit OS respectively) and start it with administrative rights:

C:\Windows\System32\cmd.exe /C start "VisualBasic6" /D "C:\Program Files (x86)\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.EXE"

C:\Windows\System32\cmd.exe /C start "VisualBasic6" /D "C:\Program Files\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE"

In case this doesn't work, try making your project outside the VB6 IDE using the aforementioned method. For example, assuming you need to build a project named testproj.vbp in path C:\MyProjects\TestProj, use the following command (for 64 and 32 bit OS respectively) in an elevated Command Prompt:

start "VisualBasic6" /D "C:\Program Files (x86)\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.EXE" /make "C:\MyProjects\TestProj\testproj.vbp" /outdir "C:\MyProjects\TestProj"

start "VisualBasic6" /D "C:\Program Files\Microsoft Visual Studio\VB98" /AFFINITY 1 "C:\Program Files\Microsoft Visual Studio\VB98\VB6.EXE" /make "C:\MyProjects\TestProj\testproj.vbp" /outdir "C:\MyProjects\TestProj"

Unfortunately, VB6 doesn't give an indication that compilation has finished, so you need to track the VB6 process in task manager (when compilation finishes the VB6 process will just terminate).

Just for your reference, I'm running VB on a Windows Server 2012 with 2 Intel Xeon quad-core CPUs.

0
On

I tried each of PhoeniX_2 suggestions. None of them worked. I don't know what made me try this, but the last time I compiled, I created a new exe filename than used during my previous version. Thankfully it worked. I can't understand why. It was not a permission issue or locked file issue. I thought that it might have been because a new compile overwrites the previous compile's exe file. The computer was also restarted a few times over the 2 day period of troubleshooting.

So if none of Phoenix's suggestions work for you, then try compiling a new exe filename than created with your previous compile.

1
On

I've (surprisingly) had a similar issue to this before.

The best solution is to start making changes to your project settings.

Right-click your project and go to Properties. Under the "Compile" tab, go to Advanced Optimizations. Turning off "Assume No Aliasing" is probably your best bet. However, if that button is disabled, try switching from P-Code to Native Code.

If the change above didn't work, and you weren't already in P-Code, try P-Code.

Lastly, if you really want to stick to Native Code, try choosing No Optimization.

If things still don't seem to work, simply go through settings and unchecking different optimizations.

If you're still having an issue after all of that, try opening up each form and other file in your project, and see if a specific file is simply corrupt, which could lead to the sudden exit. At least this way you could trace it to a file.

If after all that fails, try compiling it on a different operating system - but I really doubt it'll get to that point.

Good luck!

0
On

I've found the cause for us. We had user controls that are trying to connect to database during Initialize event. This is a really bad idea because this event runs during compiling as well as during IDE loading. It hung for long periods trying to connect to the database that didn't exist, and then crashed the compile process so no Exe was produced (though there was no visible sign).

The solution was to do the db connection and other startup code in a public method called from the form Load event. There doesn't seem to be any reliable way to use Initialise.

0
On

I'm using Windows 10 and got the same problem. In my case I tried to change the exe file name and for the first few times it worked. However, it got stuck again and after closing some other running applications (Visual Studio 2010, Firefox, Explorer...), restarting vb6 and compiling again, it worked again without renaming the exe file.

0
On

Personally I had all kinds of issues with the VB6 IDE in Windows XP and later.

I keep a Virtual Machine running Windows 2000 and do any VB6 work in that.

I have few problems with it. If there is any weirdness I simply revert the VM to a baseline install.