Share via


COM and DCOM Migration (Windows Embedded CE 6.0)

1/6/2010

This topic contains information about migrating this functionality from earlier versions of Windows Embedded CE.

For general migration information, see Migrating from an Earlier Version of Windows CE.**

Note

Distributed COM (DCOM), sometimes also referred to as "COM Remoting", is not included in Windows Embedded CE. Please see Remote DCOM Support for more information.

Migrating from Windows CE 2.12 and Windows CE 3.0

With the introduction of DCOM in Windows CE .NET 4.0, compliance with COM rules is required because DCOM supports multiple apartment models and DCOM objects have a strong affinity for the apartments they occupy. In addition, the DCOM code base was consolidated with the small in-proc only COM code base.

For example, the following COM rules are now enforced:

  • The requirement to initialize apartments before using COM.
  • Regarding reference counting for CoInitializeEx and CoUninitialize: Calls to CoInitializeEx must be paired with an equal number of calls to CoUninitialize. Prior to Windows CE .NET 4.0, CoInitializeEx was an empty function and paired calls were not required.
  • Rules on apartment declarations for COM objects. The previous COM implementation only supported multithreaded apartments but still allowed loading of objects declared as single-threaded.

As a result of these changes, Windows CE .NET 4.0 and later are not backwards compatible with older applications that do not comply with these requirements. To partially rectify this problem without requiring changing code or adding registry entries, the following changes were made in Windows CE .NET 4.0:

  • For executable (.exe) files linked using tools prior to version 4.0, if an apartment was not initialized before using COM functionality, the apartment is automatically initialized to multithreaded when a COM API function is called.
    This causes a memory leak when the thread terminates, but it enables the application to run. This approach does not work with .dll files.
  • To enable older .dll files hosted in newer executables, you can use the registry to identify executables that should be automatically initialized.
    To do this, add a new DWORD entry to the HKEY_LOCAL_MACHINE\Software\Microsoft\OLE\LegacyApps key. The new entry should have the same name as the executable and a value of 1.
    This step is only necessary for executables that load .dll files.
  • Any declaration of apartment requirements in the registry is ignored for .dll files that were linked using tools prior to version 4.0. Instead, the apartment requirement is automatically set to free-threaded.
  • The DEFAULT apartment type on Windows CE .NET 4.0 and later is free-threaded, in contrast to Windows, where it is single-threaded. This apartment type is used if one is not declared in the registry.

See Also

Other Resources

Component Services (COM and DCOM)