A DLL (dynamic-link library) is a file of shared code and data that several Windows programs can use at the same time. If an error says a DLL “was not found” or “is missing”, don’t download the file from a DLL download site. Get it back through the official route instead: reinstall or repair the app, install the Microsoft Visual C++ v14 Redistributable from Microsoft, run Windows Update, then run DISM and sfc /scannow. That fixes most DLL errors on Windows 11 version 26H2 and earlier supported versions, and it avoids the malware risk of loose DLL files.
The rest of this page covers how dynamic linking works, DLL dependencies, DLL entry points, exporting DLL functions and DLL troubleshooting tools. It ends with a comparison of DLLs and.NET assemblies.
On Windows, DLLs supply much of what the operating system does. When you run a program, DLLs also supply a lot of what that program does. Some programs are split into modules, and each module ships as its own DLL.
Why Windows uses DLLs
DLLs help keep code modular, let programs reuse code, use memory more efficiently and take up less disk space. As a result, Windows and your programs load faster, run faster and take less room on the drive.
The trade-off is dependency. When a program uses a DLL, it depends on that DLL. If another program overwrites or breaks the DLL, the first program may stop working.
The.NET Framework, and later modern.NET, removed most of these dependency problems by using assemblies.
How a DLL works
A DLL is a library of code and data that more than one program can use at the same time. For example, Comdlg32.dll handles Windows’ common dialog boxes. Any program can use the code in this DLL to show a standard Open dialog box. That promotes code reuse and efficient memory use.
A DLL also lets a developer split a program into separate parts. An accounting program, for example, can be sold as modules. Each module is loaded into the main program at run time only if it is installed. Because the modules are separate, the program starts faster, and a module loads only when you use its features.
Updates are easier too. A developer can update one module without touching the rest of the program. Say you have a payroll program and the tax rates change every year. If the tax rules live in a DLL, the vendor can ship an update to that DLL without rebuilding or reinstalling the whole program.
Several common Windows file types are really DLLs:
ActiveX controls (.ocx files)
An example of an ActiveX control is a calendar control that lets you pick a date from a calendar.
Control Panel items (.cpl files)
An example of a.cpl file is an item you see in Control Panel. Each item is a specialised DLL.
Device drivers (.drv files)
An example of a device driver is a printer driver that manages printing to a printer.
DLL advantages
Using a DLL gives a program three main benefits.
Uses fewer resources
When several programs use the same library of functions, a DLL cuts down on duplicate code loaded on the disk and in physical memory. That helps the program running in the foreground and every other program running on Windows.
Promotes modular architecture
DLLs make it easier to build modular programs. They help with large programs that need several language versions, or programs built from separate parts. An accounting program with many modules that load at run time is a typical example.
Eases deployment and installation
When a function inside a DLL needs an update or a fix, the vendor can replace the DLL without relinking the program. If several programs use the same DLL, they all get the fix. This matters most with third-party DLLs that are updated or patched often.
DLL dependencies
When a program or a DLL calls a function in another DLL, a dependency is created. The program is no longer self-contained, and it can break if that dependency breaks. For example, the program may fail to run if any of these things happen:
- A DLL it depends on is updated to a new version.
- A DLL it depends on is repaired.
- A DLL it depends on is overwritten with an older version.
- A DLL it depends on is removed from the computer.
These are known as DLL conflicts, often called “DLL hell”. If the new DLL is not backward compatible, the program may not run correctly.
Windows 2000 and later versions added features to reduce these problems.
Windows Resource Protection
Windows Resource Protection stops unauthorised programs from replacing or deleting system DLLs. It replaced Windows File Protection, which shipped in Windows 2000, Windows XP and Windows Server 2003, starting with Windows Vista and Windows Server 2008. Today it protects essential system files, folders and registry keys, and only the TrustedInstaller account (through the Windows Modules Installer service) has full rights to change them. In practice that means only Windows Update and Microsoft’s supported installers can replace a protected system DLL.
Private DLLs
Private DLLs shield a program from changes made to shared DLLs. To use them, a developer puts the DLLs in the program’s own folder. Newer programs normally pair this with an application manifest that names the exact DLL versions they need. Older programs could use an empty.local file (for example, App.exe.local) to tell Windows to prefer the copies in the program folder. Either way, Windows loads the private copies in the program folder first.
How to fix a missing DLL error safely
Repair the program or the Windows component that owns the DLL, never the single file. A DLL copied from a download site may be the wrong version or the wrong architecture (32-bit vs 64-bit), or it may be malware. Even a clean copy dropped into the wrong folder can cause new errors. Work through these steps in order, from quickest to most involved:
- Restart the PC. A pending update or a locked file sometimes clears itself after a restart.
- Repair or reinstall the program that shows the error. On Windows 11, go to Settings > Apps > Installed apps, select the three dots next to the app, then choose Modify or Advanced options > Repair if offered. If not, uninstall it and install it again from the vendor’s own site or the Microsoft Store. This puts back the exact DLLs the program expects.
- Install the Microsoft Visual C++ Redistributable. Errors naming MSVCP140.dll, VCRUNTIME140.dll or VCRUNTIME140_1.dll mean the C++ runtime is missing or damaged. Download the latest supported v14 Redistributable from Microsoft’s “Latest Supported Visual C++ Redistributable Downloads” page on Microsoft Learn. It covers programs built with Visual Studio 2017 through 2026. On 64-bit Windows, install both the x64 and x86 versions, because 32-bit programs need the x86 one. You can also install it from an elevated Terminal with
winget install, id Microsoft.VCRedist.2015+.x64, exact(and the same command withMicrosoft.VCRedist.2015+.x86). - Run Windows Update. Go to Settings > Windows Update > Check for updates and install everything offered, including optional.NET and driver updates.
- Repair Windows system files. Open Terminal (Admin), run
DISM.exe /Online /Cleanup-image /Restorehealth, wait for it to finish, then runsfc /scannow. DISM pulls clean files from Windows Update, and System File Checker then repairs protected system DLLs. Restart when done. - Scan for malware. Open Windows Security > Virus & threat protection > Scan options and run a Microsoft Defender Offline scan. Malware sometimes deletes DLLs or poses as them.
If the error still appears after step 5 and it names a Windows system DLL, contact the program’s vendor or Microsoft support. An in-place repair install of Windows may be the next step, so back up your files first.
DLL troubleshooting tools
Several tools help you find DLL problems. Some are current; others are older tools that are useful mainly as background.
Dependency Walker
Dependency Walker (Depends.exe) scans a program and lists every DLL it depends on, layer by layer. When you open a program in Dependency Walker, it checks for:
- Missing DLLs.
- Program files or DLLs that are not valid.
- Import functions and export functions that do not match.
- Circular dependency errors.
- Modules that are not valid because they were built for a different operating system.
With Dependency Walker you can record every DLL a program uses, which helps you prevent and fix DLL problems later. It used to be installed with Visual Studio 6.0 in the following folder:
drive:\Program Files\Microsoft Visual Studio\Common\Tools
Dependency Walker has not been updated in years. On Windows 7 and later it often reports false errors for API set names such as api-ms-win-*.dll, which Windows redirects internally. On Windows 11, a more reliable built-in option for developers is dumpbin /DEPENDENTS program.exe, run from the Visual Studio Developer Command Prompt. It lists the DLLs a program imports functions from. To see which files a program actually tries to load while it runs, Process Monitor from Microsoft Sysinternals works well.
DLL Universal Problem Solver
The DLL Universal Problem Solver (DUPS) was a Windows 2000-era tool for auditing, comparing, documenting and displaying DLL information. Microsoft no longer offers it. It was made up of these utilities:
- Dlister.exe listed all the DLLs on the computer and logged the information to a text file or a database file.
- Dcomp.exe compared the DLLs listed in two text files and produced a third text file with the differences.
- Dtxt2DB.exe loaded the text files created by Dlister.exe or Dcomp.exe into the dllHell database.
- DlgDtxt2DB.exe was a graphical version of Dtxt2DB.exe.
DLL Help database
The DLL Help database helped you find which versions of a DLL were installed by Microsoft software products. Microsoft retired it long ago. Today, file properties (right-click the DLL, then Properties > Details) show the version and product name.
DLL development
This section covers the issues and requirements to think about when you write your own DLLs.
Two ways to link a DLL
When an application loads a DLL, it can call the DLL’s exported functions in two ways: load-time dynamic linking and run-time dynamic linking.
Load-time dynamic linking
With load-time dynamic linking, an application calls exported DLL functions as if they were local functions. To use it, you supply a header (.h) file and an import library (.lib) file when you compile and link the application. The linker then gives Windows the information it needs to load the DLL and find the exported functions when the program starts.
Run-time dynamic linking
With run-time dynamic linking, an application calls the LoadLibrary or LoadLibraryEx function to load the DLL while it runs. Once the DLL is loaded, you call GetProcAddress to get the address of the exported function you want. You do not need an import library file.
Choosing between them
These criteria help you decide which method fits your application:
- Startup performance: if fast startup matters, use run-time dynamic linking, so DLLs load only when needed.
- Ease of use: with load-time dynamic linking, exported DLL functions behave like local functions, which makes them simple to call.
- Application logic: with run-time dynamic linking, an application can choose which modules to load as it goes. That is useful when you build several language versions.
The DLL entry point
When you create a DLL, you can specify an entry point function, usually called DllMain. Windows calls it when processes or threads attach to the DLL or detach from it. You can use it to set up or clean up data structures the DLL needs. If the application is multithreaded, you can also use thread local storage (TLS) in the entry point function to give each thread its own private memory. Here is a basic entry point:
#include <windows.h>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
// A process is loading the DLL.
break;
case DLL_THREAD_ATTACH:
// A process is creating a new thread.
break;
case DLL_THREAD_DETACH:
// A thread is exiting cleanly.
break;
case DLL_PROCESS_DETACH:
// A process is unloading the DLL.
break;
}
return TRUE;
}
If the entry point returns FALSE during DLL_PROCESS_ATTACH and you use load-time dynamic linking, the application will not start. With run-time dynamic linking, only that DLL fails to load, and LoadLibrary returns NULL.
The entry point should do only simple setup work. It should not call other DLL loading or unloading functions. For example, it must not call LoadLibrary or LoadLibraryEx, directly or indirectly. It also must not call FreeLibrary while the process is ending.
Note: in multithreaded applications, make sure access to the DLL’s global data is synchronised (thread-safe) to avoid data corruption. One way is to use TLS to give each thread its own copy of the data.
Exporting DLL functions
To export DLL functions, you either add a keyword to each exported function or create a module definition (.def) file that lists them.
To use the keyword, declare each function you want to export with:
__declspec(dllexport)
To use exported functions in an application, declare each function you import with:
__declspec(dllimport)
Usually you write one header file with a #define and an #ifdef so the same declaration exports when you build the DLL and imports when you build the application:
// SampleDLL.h
#ifdef SAMPLEDLL_EXPORTS
#define SAMPLEDLL_API __declspec(dllexport)
#else
#define SAMPLEDLL_API __declspec(dllimport)
#endif
SAMPLEDLL_API void HelloWorld(void);
You can also use a module definition file. Then you don’t need the keyword on each function. In the.def file you write a LIBRARY statement and an EXPORTS statement for the DLL:
; SampleDLL.def
LIBRARY "SampleDLL"
EXPORTS
HelloWorld
Where Windows looks for a DLL
When an application that uses SampleDLL starts, Windows first checks a few special sources: DLL redirection, API sets, side-by-side manifest redirection, DLLs already loaded in memory, and the KnownDLLs list. If the DLL isn’t found there, Windows searches these folders in order. Safe DLL search mode is on by default and has been since Windows XP Service Pack 2:
-
The folder the application was loaded from.
-
The Windows system folder (System32).
Note:
The GetSystemDirectory function returns the path of the Windows system folder.
-
The 16-bit system folder (System).
-
The Windows folder.
Note: the GetWindowsDirectory function returns the path of the Windows folder.
-
The current folder.
-
The folders listed in the PATH environment variable.
Safe DLL search mode puts the current folder near the end of the list. This order is also why you should never copy random DLLs into the System32 folder or a program’s folder. A malicious DLL placed in a folder Windows searches early can be loaded instead of the real one, an attack known as DLL hijacking or DLL planting.
.NET assemblies compared with DLLs
The.NET Framework, and modern.NET after it, solved most classic DLL problems with assemblies. An assembly is a logical unit of functionality that runs under the control of the.NET common language runtime (CLR). Physically it is a.dll or.exe file, but inside it is very different from a Win32 DLL. The current versions are.NET Framework 4.8.1, which ships with Windows, and.NET 10, a long-term support release from November 2025 that is supported until November 2028.
An assembly file contains an assembly manifest, type metadata, Common Intermediate Language (CIL) code (once called MSIL) and other resources. The manifest holds the metadata that makes the assembly self-describing. It includes:
- The assembly name.
- Version information.
- Culture information.
- Strong name information.
- The list of files in the assembly.
- Type reference information.
- Information about referenced and dependent assemblies.
CIL code cannot run directly. The CLR compiles and manages it. By default, an assembly you build is private to your application. In the.NET Framework, a shared assembly needs a strong name and goes into the global assembly cache (GAC). Modern.NET (.NET Core,.NET 5 and later) does not use the GAC. Apps ship the assemblies they need in their own folder or rely on a shared runtime that is installed separately.
Here is how assemblies compare with Win32 DLLs.
Self-describing
The manifest holds everything the CLR needs to run the assembly, including the list of assemblies it depends on. The CLR can therefore keep a consistent set of assemblies for each application. With shared Win32 DLLs, nothing keeps the set of DLLs an application uses consistent.
Versioning
The manifest records version information, and the runtime enforces it. In the.NET Framework, version policies let you force a specific version. With Win32 DLLs, Windows cannot enforce versions, so developers must keep DLLs backward compatible.
Side-by-side deployment
Assemblies support side-by-side deployment. One app can use one version of an assembly while another app uses a different version. For Win32 programs, Windows has supported side-by-side assemblies since Windows XP, which let different applications use different versions of the same shared DLL. Windows Resource Protection, the successor to Windows File Protection, stops unauthorised programs from overwriting or changing system DLLs.
Self-containment and isolation
An application built with assemblies can be self-contained and isolated from other applications on the computer. That makes zero-impact installs possible. Modern.NET goes further: a self-contained app ships with its own copy of the runtime.
Security
In the.NET Framework, an assembly runs under security permissions requested in its manifest and enforced by the CLR (Code Access Security). Modern.NET dropped Code Access Security. It relies on the operating system’s own security, such as user accounts and file permissions.
Language independence
You can write an assembly in any supported.NET language. For example, you can build an assembly in C# and then use it in a Visual Basic project.
FAQ
Is it safe to download DLL files from DLL download websites?
No. These sites are not official sources, and their files may be outdated, built for the wrong architecture or bundled with malware. Even a clean file usually doesn’t fix the real problem, which is a broken program or a missing runtime. Reinstall the app or install the runtime it needs from Microsoft or the app’s vendor instead.
What does “VCRUNTIME140.dll was not found” mean?
It means the Microsoft Visual C++ runtime that the program was built with is missing or damaged. Install the latest supported Visual C++ v14 Redistributable from Microsoft Learn, both the x64 and x86 versions on 64-bit Windows, then restart. The same fix covers MSVCP140.dll and VCRUNTIME140_1.dll errors.
Can I delete DLL files to free up space?
Don’t delete DLLs by hand. A DLL that looks unused may be needed by Windows or by a program you open only now and then, and deleting it can stop that program from starting. To free space, uninstall programs you don’t need from Settings > Apps > Installed apps or use Settings > System > Storage.
Can a DLL file be a virus?
Yes. A DLL can contain malicious code, and attackers sometimes plant a fake DLL in a folder Windows searches early so a trusted program loads it. That is one more reason never to copy DLLs from unknown sources into System32 or a program folder. If you suspect an infected DLL, run a Microsoft Defender Offline scan from Windows Security.
What is the difference between a DLL and an EXE file?
An EXE is a program you can start on its own. A DLL holds code that other programs load and call, so it cannot run by itself. Both use the same Windows Portable Executable (PE) file format, which is why tools such as dumpbin can inspect either one.
Do I need to register a DLL with regsvr32?
Usually not. Only COM DLLs and ActiveX controls need registering, and the program’s installer normally does it for you. If an app asks you to re-register a DLL, follow the vendor’s instructions, and reinstalling the app is usually the cleaner fix.
Sources
- Dynamic-link library search order (Microsoft Learn)
- Dynamic-link library security (Microsoft Learn)
- Latest Supported Visual C++ Redistributable Downloads (Microsoft Learn)
- About Windows Resource Protection (Microsoft Learn)
- Use the System File Checker tool (Microsoft Support)
-
/DEPENDENTS dumpbin option (Microsoft Learn)
-.NET Framework Support Policy (Microsoft) -
Windows 11, version 26H2 known issues and notifications (Microsoft Learn)












