Registering DLLs and EXEs Manually

Have you ever run across a “File name or class name not found during OLE Automation operation” error message, like this?

Error - OLE Automation Dialog

Hopefully it was not right after rolling out a customization to all of your users.  The bad news?  Windows didn’t recognize a class library that the application (or script) was calling.  The good news?  It might not be as bad as it looks.  There is a decent chance that everything is OK with your application with one small exception; one or more key files are improperly registered (or not registered at all).  This article will describe how to manually register some of these key file types (like DLLs) to address this issue. 

DLLs, TLBs, OCXs and ActiveX EXEs all have at least one thing in common:  metadata about them is stored in the Windows registry.  This metadata is normally added to the registry during a product installation, but can also be added quite easily from a command prompt.  This is important in cases where a developer has improperly built an installation package or any other case where a registry entry is missing or has somehow become corrupt.  Windows has several built-in tools that make registering these components a snap. 

Dynamic Link Libraries (DLLs)

A DLL is a library that contains code and data that is referenced by one or more applications.  There are various types of DLLs (and not all have .dll extension), but only COM DLLs require a registry entry to help Windows find them. 

To register a DLL, use regsvr32.exe as follows:

  1. Select Start -> Run
  2. In the dialog box, type the following:

Regsvr32 <full path of DLL to be registered>

For example, regsvr32 C:\RLSmUtils.dll would register the library named RLSmUtils.  If successful, you’ll see the message:

RegSvr32 Dialog Box 

Type Libraries

Type libraries contain information about the interfaces used within a DLL.  These are common when developing COM-visible DLLs in .NET.  The type library rather than the DLL gets registered.

To register a type library, use regtlibv12:

  1. Select Start -> Run
  2. In the dialog box, type the following

Regtlibv12 <full path to the type library>

For example, regtlibv12 C:\Program Files\Razorleaf\MyTypeLib.tlb would register the library MyTypeLib.  If successful, a dialog box similar to the one shown for the DLL will appear.

ActiveX Controls

ActiveX Controls are actually DLLs with an .OCX extension and are registered in the same fashion.  Refer to the section on DLLs and use the path to the OCX file.

ActiveX Servers

ActiveX servers can take the form of DLLs and EXEs.  ActiveX Server DLLs are registered in the same way as the traditional DLLs (see above).  However, ActiveX EXEs are slightly different.

To register an ActiveX Server:

  1. Select Start -> Run
  2. In the dialog box, type the following:

<Full path of the EXE file> /RegServer

For example, C:\Program Files\Razorleaf\MyEXE.exe /RegServer will register the ActiveX Server MyExe.exe.

Hopefully, these quick tricks will get you back on course and resolve your OLE Automation error.  If not, good luck with further troubleshooting, or contact us to see if we can help further.

Share and Enjoy:
  • Digg
  • Facebook
  • del.icio.us
  • Google Bookmarks
  • LinkedIn
  • Mixx
  • MySpace
  • NewsVine
  • Ping.fm
  • Sphinn
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Buzz
  • Print
  • email
  • RSS

Tags: , , , , , ,

Read more posts by

This entry was posted on Tuesday, November 24th, 2009 at 5:00 pm and is filed under Developer's Corner, Development / Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.