Search code examples
delphidelphi-xe7delphi-10.1-berlin

Unable to cast COM object (Delphi XE7 - Delphi Berlin incompatibility)


I installed Delphi Berlin recently. Didn't worked so I uninstalled it same day. Now my Delphi XE7 stopped working. I get this error when I try to compile anything, and I don't know how to fix it.

Unable to cast COM object of type 'System.__ComObject' to interface type 'Borland.Studio.Interop.IInteropMessageService'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FF877130-F96F-3885-9A3E-3093A3C1D831}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))

The error is just like shown above. No source file is mentioned.


I already tried to use the 'fix' provided by Embarcadero but their tool won't work:

C:\Delphi\Delphi XE7\bin>tregsvr -t Borland.Studio.Interop.tlb
Embarcadero Turbo Register Server(32) -- COM Server Registration utility.
Version 1.3  Copyright (c) 1997-2010 Embarcadero Technologies, Inc.

Type library name: C:\Delphi\Delphi XE7\bin\Borland.Studio.Interop.tlb
Type library GUID: {F939BACD-3FD5-437A-833F-BA3535A45966}

Error: Error accessing the OLE registry

FIX (suggested by @rruz): the utility above needs to be run under "Admin" (elevated) permissions. Thanks @RRuz.


Solution

    1. Open a command prompt as admin.
    2. Go to the folder where your current Delphi version is installed (example "c:\Delphi\Sydney\bin")
    3. Run "tregsvr -t Borland.Studio.Interop.tlb"