Click here to Skip to main content
15,886,199 members
Articles / Operating Systems / Windows

Use RegFree to Solve DLL Hell Even With COM Clients

Rate me:
Please Sign up or sign in to vote.
2.52/5 (8 votes)
25 Feb 20072 min read 39.4K   25   3
An article on using the RegFree capabilities of XP SP2 to solve DLL Hell.

Introduction

This article presents a method of using the RegFree feature even with COM client applications. RegFree is a new capability of Windows to use a local XML file rather than the Registry for the interface details.

Note: "Registry Free" COM is available only on Windows XP SP2, Windows Server 2003, or newer Windows OSs. If you are working with one of these, then you can take advantage of the following method from both your unmanaged applications (COM) as well as your managed ones.

Overview

Prior to .NET, COM components needed to be globally registered on the machine. It was assumed that any new version of a component would replace the previous version, but maintain compatibility with the older version's clients. The term DLL Hell arose to describe the situation in which that compatibility was not preserved. Here is an example of such a situation:

  1. Your application requires the latest version of a third-party OCX.
  2. An application on your customer's machine requires an older version of that third-party OCX.
  3. Neither application works with the OCX version required by the other application.

How to Create the XML Manifest

RegFree COM works by expressing all of the standard component registration information that is typically installed into the system Registry in a file that can be stored in the same folder as the application itself. Getting this file is the difficult part. Luckily, Visual Studio 2005 can do 99% of the work required regardless of whether your client is .NET or VB, or even if you are not the developer of the client.

The method is to create a dummy project (named "Dummy") in VS 2005, set a reference to the COM component(s) you wish to create the XML manifest for, and set its "Isolated" property to True.

When you build the project, the bin/debug or bin/release folder will then have a file titled "Dummy.exe.manifest".

  1. Rename the "Dummy" portion of this file to match your executable.
  2. Open the manifest, and search and replace "Dummy" with the name of your executable.
  3. Finally, place the file in the same location as your executable, along with the copy of the third party component(s) that you require.

Now, it doesn't matter what version of that third-party component is registered on the machine, your application will always use the one in its executable directory.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Canada Canada
Darrin Doherty is founder and CEO of Anjin Consulting Inc., providing custom solutions to the field service industry. Their latest online endeavor is Rep-Protect.com, helping companies protect their online reputations.

Comments and Discussions

 
Questionexported from a .NET assembly and cannot be added as a reference Pin
Patrick Wolf15-Apr-07 15:19
Patrick Wolf15-Apr-07 15:19 
GeneralPrerequisits to make this work Pin
jerchap27-Feb-07 6:04
jerchap27-Feb-07 6:04 
What version of windows does this work with? Does this work with any exe, no matter what it's written in?
GeneralRe: Prerequisits to make this work [modified] Pin
DarrinDoherty27-Feb-07 6:58
DarrinDoherty27-Feb-07 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.