PRB: "Error Loading DLL" If VB .EXE Has Same Name as DLL

Last reviewed: June 21, 1995
Article ID: Q79598
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0

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 "Error Loading DLL" 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 "Error Loading DLL"), 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 reference words: 1.00 2.00 3.00
KBCategory: kbenv kbprg kbinterop kbprb
KBSubcategory: EnvtRun


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.