Article ID: 145676 - Last Review: December 9, 2003 - Revision: 2.0 PRB: Registry Overwritten with Same ProgID/Different Bitness ServerThis article was previously published under Q145676 On This PageSYMPTOMS
On a single machine, developing and using 16-bit and 32-bit OLE servers
that provide objects with the same ProgID may cause problems if no
compatible server is specified. Some registry entries will point only to
the last server registered and only this server may be accessible from OLE
Automation clients.
This article illustrates why this behavior occurs, and also explains how to avoid this problem. RESOLUTION
If development of both 16-bit and 32-bit servers is done on the same
machine, this problem can be avoided by specifying a compatible server for
your OLE server project. If a compatible server exists, the CLSID from the
compatible server will be used when any new executable is created. In the
above scenario, this means that only one key CLSID will be used for the
server. Instead of one CLSID possessing a LocalServer key and another
containing a LocalServer32 key, both LocalServer and LocalServer32 keys
will exist beneath the same CLSID. When more than one server is listed
beneath a CLSID, OLE has a predefined order that is used to determine which
server is used to provide the object.
MORE INFORMATION
Two of the most important keys that are created by registration of an OLE
server are a ProgID key and a CLSID key. The ProgID is created immediately
beneath the HKEY_CLASSES_ROOT predefined key and consists of the
ProjectName.ClassName for a Visual Basic OLE server. The single key created
beneath this ProgID key is named CLSID; its value is a 64-bit number that
is used by OLE to uniquely identify the particular object. In addition to
the ProgID and file extension keys off of HKEY_CLASSES_ROOT, there is also
a key just named CLSID. Expanding this key will show subkeys for each CLSID
that is registered on the machine. There will be a key with the same 64-bit
number associated with the ProgID in this section. Keys underneath this
individual CLSID hold information that OLE uses to access the server.
When classes provided by a 32-bit out-of-process (EXE) OLE server are registered, two of the keys created beneath the CLSID for each class are named LocalServer32 and InprocHandler32. Registration of a 16-bit server causes the creation of LocalServer and InprocHandler keys. The InprocHandler key specifies the OLE DLL to be used by the client for communication with the server. The DLL used by local Visual Basic OLE servers is OLE2.DLL on 16-bit machines, and OLE32.DLL on 32-bit Windows operating systems. The LocalServer(32) key contains the path and filename of the executable for the server. With an out-of-process server created with Visual Basic, this will be the executable generated by Visual Basic. The problem addressed by this article occurs when 16-bit and 32-bit versions of an OLE server are registered and provide objects with the same ProgID but different CLSIDs. This can easily happen if, for example, a 16- bit OLE server project is loaded into the 32-bit version of Visual Basic and a new 32-bit executable is created. Starting with a fresh machine, registering (via compilation perhaps) a 32-bit server will create these registry entries (among others):
HKEY_CLASSES_ROOT\ProjectName.ClassName
and
HKEY_CLASSES_ROOT\ProjectName.ClassName\CLSID = <CLSID for 32-bit server>
HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server> HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server>\LocalServer32 Where LocalServer32 points to the 32-bit executable. If a client requests an object of ProjectName.ClassName, the 32-bit EXE will be started and used to provided the object. Now suppose a 16-bit server is now registered with the same ProgID of ClassName.ProjectName. The registry will contain these relevant entries (where the ones marked with asterisks are new or modified):
HKEY_CLASSES_ROOT\ProjectName.ClassName
and
*HKEY_CLASSES_ROOT\ProjectName.ClassName\CLSID = <CLSID for 16-bit server>
*HKEY_CLASSES_ROOT\CLSID\<CLSID for 16-bit server> *HKEY_CLASSES_ROOT\CLSID\<CLSID for 16-bit server>\LocalServer
HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server> HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server>\LocalServer32 If a client now requests an object of ProjectName.ClassName, OLE will look up the ProgID and use the value of the CLSID beneath the ProgID to determine what object to create. This value is now the CLSID for the 16- bit server, so the server that will be started to provide the object will be the EXE pointed to by the LocalServer key of the new CLSID that was added by the registration of the 16-bit server. Furthermore, if the 16-bit server is now unregistered, not only will the newly added CLSID keys be removed, but the ProgID key will be removed also. At this point the 32-bit server will be unable to provide objects, despite the fact that it has not been unregistered. Because the ProgID key is gone, the CLSID keys that the 32-bit server added are orphaned and OLE has no way to access them. Reregistering the 32-bit server will add the correct ProgID and enable the 32-bit server to again provide objects. Steps to Reproduce
| Article Translations
|
Back to the top
