Printer Friendly Version      Send     
Click to Rate and Give Feedback
Related Articles
This Tip will explain how to send email from Exchange ...

Read more!

New Tip ...

Read more!

A tip on how to write amazing fast queries. ...

Read more!

Make a new tip by beating yourself in the head with a keyboard ...

Read more!

Also by this Author

Why can't you copy a list of files in Windows Explorer and then paste them as text to get their file names? The Windows team tried to include this functionality, but it didn't work as planned.

Raymond Chen

TechNet Magazine August 2007

...

Read more!

Ever wonder why you need a miniature file system driver built into those critical boot files?

Raymond Chen

TechNet Magazine November 2007

...

Read more!

Raymond Chen discusses the intriguing backstory of how naming conventions for non-final releases have changed. And he gives a gentle plea for companies to take beta testing more seriously.

Raymond Chen

TechNet Magazine March 2008

...

Read more!

Why does using Dr. Watson to take a memory dump of Winlogon bring down the entire system? This isn’t an accident. Explore the world of Task Manager and critical system files to find out why.

Raymond Chen

TechNet Magazine October 2007

...

Read more!

Raymond Chen explains why Windows can but chooses not to replace a file that is currently in use.

Raymond Chen

TechNet Magazine November 2008

...

Read more!

Popular Articles

Michael Murgolo is back with an update to his Elevation PowerToys. You'll find enhanced Run as Administrator functionality that works with third-party scripting tools, a way to replace a handy Windows XP feature removed from Windows Vista, and many more useful tools.

Michael Murgolo

TechNet Magazine June 2008

...

Read more!

User Account Control, or UAC, is one of the most misunderstood new features in Windows Vista. But its goal—to enable users to run with standard user rights—can solve many security issues. Get an inside look at the problems UAC is designed to address and see exactly how this new feature works.

Mark Russinovich

TechNet Magazine June 2007

...

Read more!

Wikis offer a new, more flexible way to collaborate, promoting an unstructured approach to thinking and exchanging ideas. And MOSS 2007 makes it incredibly easy to implement wikis in your organization. Here’s what you need to know to start building and using wikis in the workplace.

Mauro Cardarelli

TechNet Magazine January 2007

...

Read more!

Backup is something many people ignore until it’s too late. But there’s no excuse for this, especially now that the new Windows Vista Backup and Restore Center offers a variety of features that make it easy to protect your data against most forms of data loss. Find out how you can plan a complete recovery strategy with Windows Vista.

Christine Fok

TechNet Magazine September 2007

...

Read more!

With Windows Vista, changes to the OS kernel bring about advances in many areas, ranging from memory management to reliability to security. We kick off this series with a look at how the kernel delivers improvements in the areas of processes, threads, and I/O.

Mark Russinovich

TechNet Magazine February 2007

...

Read more!

Our Blog

In every issue of TechNet Magazine, Greg Steen (a practicing IT professional) discusses free and relatively inexpensive tools and utilities that help him do his IT work and "getting the job done." 

In the November issue, Greg looks at mapping data graphically with MapForce, creating and managing ...

Read more!

Have you ever wondered why you sometimes get a message that says Windows can't replace a file that is currently in use? In the November 2008 issue of TechNet Magazine, Raymond Chen looks at the underlying reason for this and explains why it would be more accurate to say Windows can but has chosen not to ...

Read more!

"For developers, one difficult problem in SQL Server is tracking what data has changed in a database. An even greater challenge is architecting a simple solution that doesn’t heavily impact workload performance and isn't difficult to create, implement, and manage. So why go to all the trouble to track changes? Is tracking changes really worth all this effort? Two commonly cited examples are to support updates to a data warehouse and to support the synchronization of heterogeneous, occasionally connected systems." ...

Read more!

The latest installment of our online-only Sustainable Computing column is now available.

Find out how you can:

Bring Windows Server 2008 and Windows Vista Power Management Settings into Compliance Bring Windows Server 2003 and Windows XP Power Management Settings into Compliance Enforce Energy-Efficient Architectures ...

Read more!

The December 2008 issue of TechNet Magazine is now available online. And it's filled with information about interop.

Find out how to integrate Linux clients with ...

Read more!

Windows Confidential Getting Out of DLL Hell
Raymond Chen


DLL HELL. A problem so insidious it has its own pejorative nickname. You install one program and suddenly some seemingly unrelated program stops working. This is because, unknown to you, the two programs are connected via a shared DLL file. The two programs might have different ideas of what version of the MSVCRT.DLL file should be in the system directory. Or the first program may upgrade an ActiveX® control that the second program uses-an upgrade that the second program is not entirely compatible with.
If both programs are essential to your company's day-to-day operations, it doesn't really matter which program is to blame. The important thing is that you need to get them up and running. There isn't much difference between "We're losing money" and "We're losing money because of Bob." Either way, your company is losing money and it's your job to fix the problem right away.
It used to be that you had to choose which program won and which program lost. Starting with Windows® 2000, bandages were made available to help you patch over these conflicts. These bandages, however, are only temporary solutions, allowing you to get your system back on its feet while you investigate a more permanent resolution to the conflict.
Windows 2000 implemented a rudimentary version of what now goes by the fancy name of Dynamic-Link Library Redirection. To enable DLL redirection, create a file with the same name as the program whose DLLs you wish to redirect, but with .local appended to the name. For example, to apply redirection to C:\Program Files\Litware Inc\Invoice.exe, create the file C:\Program Files\Litware Inc\Invoice .exe.local. The contents of the file aren't important; what's important is that the file exists.
Once you've enabled redirection for a program, all attempts by that program to load a DLL will first look in the directory that contains the program before the usual search locations. Therefore, in the case of the conflicting MSVCRT.DLL file, you can enable redirection in each program and put a private copy of MSVCRT.DLL into each program's installation directory. Each program then receives its own version of MSVCRT.DLL-the version of the DLL with which the program was tested.
The magic of this technique is that it works even if the program uses a full path to load the DLL. For example, suppose the program tries to load C:\Program Files\Common Files\Proseware Inc\taxplugin.dll. After upgrading to Proseware 2.0, you discover that its tax plug-in is incompatible with your invoice program. What you can do is copy an old version of the tax plug-in to C:\Program Files\Litware Inc\taxplugin.dll. Even though the program uses a full path to load the tax plug-in, DLL redirection will still look in the current directory and use the local override instead of the one in the Proseware Inc directory.
In Windows XP and Windows Vista™, the rules for DLL redirection are a little different, but the general principle remains the same. In addition to creating a .local file, you can also create a .local directory. In that case, the .local directory is searched rather than the program's install directory. This allows you to apply redirection to multiple programs in the same directory without conflict.
Note that you cannot apply redirection to programs that contain an application manifest, and so-called known DLLs are also exempt from redirection. (For further details, see "Dynamic-Link Library Redirection".)
DLL redirection won't entirely get you out of DLL Hell, but at least it gives you some first-aid techniques for tending the wound while you sort out the problem.
Figure 1   

Raymond Chen writes about both Windows history and Win32 programming on his Web site, The Old New Thing, as well as in his new book also titled The Old New Thing (Addison-Wesley, 2007). He does not, however, have a pet cat named The Old New Thing.
© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker