Microsoft KB Archive/79598

= PRB: &quot;Error Loading DLL&quot; If VB .EXE Has Same Name as DLL =

Article ID: 79598

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q79598



SYMPTOMS
If you create a compiled executable program that has the same base name as a dynamic link library (DLL) that is called from the program, an &quot;Error Loading DLL&quot; message will be displayed when the compiled program attempts to call the DLL. If the DLL is loaded before the .EXE program is run (for example, if the DLL is in use from another application), the executable program will not run at all.

Similarly, if an .EXE program has the same name as a loaded device driver (.DRV) and the driver is loaded before you run the .EXE program, your executable program will not run. For example, if you name your executable program TIMER.EXE, it will not run because Windows has already loaded a device driver named TIMER.DRV.



CAUSE
This behavior occurs because Windows checks, by module name, to see if a program is already loaded before it tries to execute that program. If the requested module is already loaded, Windows creates another instance of that module. Thus, attempting to load a DLL with the same module name as an already executing program will fail (usually with the error &quot;Error Loading DLL&quot;), and attempting to start an executable program with the same module name as an already loaded DLL will not execute the program.

Because the module name for a DLL is often the same as the name of the DLL itself (although this can be varied using the LIBRARY entry of the module definition file used when creating the DLL), and the module name for a compiled Visual Basic program is the same as the original base .EXE file name, attempting to load a DLL and a Visual Basic .EXE program that share the same name will often result in errors.



RESOLUTION
To avoid this problem, either recompile the Visual Basic program and change the .EXE filename, or re-create the DLL, and change the LIBRARY entry in the module definition file.



STATUS
This behavior is by design. It can occur with any Windows-based application, and may occur between any two Windows-based modules (either from executable programs or DLLs).

Additional query words: 2.00 3.00

Keywords: kbprb KB79598

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.