Visual Basic 6 applications store references to type libraries in the project (.vbp) file. VB allows you to link projects by setting references via the Project/References menu option. When you build a VB application that does not have binary compatibility enabled, VB will generate a new GUID for the typelib. Now when you wish to build any dependent VB projects, you must first remove the previous reference the old typelib and recreate the reference to the new typelib.
When building a large VB project, this process can take quite a long time. FIXVBPRef is a tool that will automatically fix missing typelib references for you.
In the VBP file, typelib references are stored in the following format
Reference=*\G{2E4F4861-542D-11D2-8B41-00C04F991474}#1.0#0#..\..\..\..\DLLs\AdStatusEventsSvr.dll#AdStatusEventsSvr 1.0 Type Library
The reference line is a # delimited string containing the following elements
To fix an invalid reference to a typelib, FIXVBPRef does the following
NOTE: FIXVBPRef will attempt to update the GUID of all referenced components, including some that may never change, therefore it must be able to load each referenced typelib.
When the vbp file was created, the typelib locations are stored using a relative path. In most cases, this allows for better location transparency since most developers tend to use the same directory structure on a project by project basis. However, there are many cases where the relative path fails to locate the typelib correctly because it may be located on a different drive or directory. FIXVBPRef will first attempt to load the typelib using the relative path stored in the vbp file. If that fails it will search in order
Most projects contain a BIN directory where the DLL and EXE files are written to. Some project further segregate binary components into subdirectories according to function or location. For example
C:\MyProject - Project root
\Source - Root
of source directories
\Test - Root of test directories
\Bin - Root of bin
directories
\Client - Contains client components and applications
\COM+ - Contains COM+ applications
\ASP - Contains ASP scripts
When FIXVBPRef cannot find a typelib it looks at the Bin root you specify as an argument on the command line and will recursively search the bin directory and all child directories for the desired typelib.
If you need to reference a component typelib that is not in the bin root, you can place a text file in the bin root directory that contains a list of directories (one per line) to recursively search as well. For example
(Sample FIXVBPRef.OPT)
C:\MyComponents\
C:\SomeThirdPartyComponent\
FIXVBPRef will look for the FIXVBPRef.opt file in the project root bin directory.
FIXVBPREF MyProject.vbp [MyBinDir]
Using a tool like FIXVBPRef you can completely automate builds of VB projects.
The sample makefile below is used to build the AdPublisher component of the Island Hopper Classifieds COM+ Sample Application
#VB Project Make File
PROJNAME=AdPublisher
PROJECT=$(PROJNAME).vbp
BINROOT=$(MSSDK)Samples\Com\Application_Samples\Island_Hopper_Classifieds\DLLs
TARGET="$(BINROOT)\$(PROJNAME).dll"
VBLOG="$(BINROOT)\VBBUILD.LOG"
#Modify the line below if you installed VB in a non-standard location
VB6="%ProgramFiles%\Microsoft Visual Studio\vb98\vb6.exe"
ALL : CLEAN $(TARGET) POSTCLEAN
CLEAN :
-@erase $(TARGET)
$(TARGET) : $(PROJECT)
fixvbpref $(PROJECT) $(BINROOT)
$(VB6) /make /out $(VBLOG) $(PROJECT)
POSTCLEAN :
-@erase $(BINROOT)\$(PROJNAME).exp
-@erase $(BINROOT)\$(PROJNAME).lib
FIXVBPRef is provided as an unsupported application sample.