PowerVB.com Home

Import Table Casing Patch (Q281913)


This is a Microsoft-provided patch for the import table dll name casing bug discussed in the readme. For convenience, the readme discussion is duplicated here.

There is an unfortunate bug in VB that creates executables with import sections that do not properly load across all operating systems. VB generates import sections when you use a type library declare for an API function. The problem occurs when you use a different casing of the dll name for multiple functions in the same Dll. This is a subtle bug in that the Exe/Dll/Ocx will generally run on the operating system it was compiled on (except possibly NT4/SP6), but will crash on any other operating system. Unfortunately, VBoostTypes used a dllname of kernel32.dll and ThreadAPI used kernel32, which VB extends automatically to kernel32.DLL. Since the threading files use both of these typelibs, this means that any threaded application built using my framework code before this update is extremely vulnerable to this bug. Also, other common typelibs, such as Bruce McKinney's typelib mention on page 422 in the book, standardized on upper case names, while I standardized on lower. This means that the VBoostTypes type library is not compatible with Bruce's win.tlb, which is clearly unacceptable. I've taken a three pronged approach to fixing this problem.
1) Standardized the VBoost type libraries to use all upper case Dll names. I would encourage you to do the same and following this casing standard in you own type libraries.
2) Created an add-in to check for this situation. This add-in appears as Import Table Casing Validation in the Add-In Manager and resides in CheckImportCasing.dll, which now builds with the other PowerVB tools. The add-in has no UI unless it catches an error, when it displays the conflicting DllNames and the type library declarations that might be causing the conflict. I would recommend that you leave this add-in running. The overhead is minimal unless an error is found.
3) Worked with Microsoft to get a patch that fixes this problem up front. The patch will be officially available after SP5 ships, but I will also be posting a version on PowerVB.com that works with SP4.

To install the patch, expand Q281913_SP4.zip into the VB98 directory (the two files must be in the same directory as VB6.exe). This will give you two new files, TlbPatch.Dll and TlbPatchLoader.Dll. 'RegSvr32 TlbPatchLoader.dll' will complete the installation. This patch works for SP4 only and will have to be updated for other service packs. You can continue to run the 'Import Table Casing Validation' add-in as a backup with minimal performance penalty.