Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Runtime.InteropServices.COMException (0x80040154): [closed]

Tags:

c#

exception

I'm getting an exception in a c# project:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {877AA945-1CB2-411C-ACD7-C70B1F9E2E32} failed due to the following error: 80040154.

What could it mean?

like image 603
Charles Ma Avatar asked Jan 11 '11 23:01

Charles Ma


People also ask

What is a COMException?

COMException(String, Exception) Initializes a new instance of the COMException class with a specified error message and a reference to the inner exception that is the cause of this exception. COMException(String, Int32) Initializes a new instance of the COMException class with a specified message and error code.


4 Answers

It means the class id 877AA945-1CB2-411C-ACD7-C70B1F9E2E32 is not in the registry.

You can verify this by opening regedit.exe, browsing to HKEY_CLASSES_ROOT\CLSID\{877AA945-1CB2-411C-ACD7-C70B1F9E2E32}. If your running a 32-bit app on a 64 bit OS, look for HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{877AA945-1CB2-411C-ACD7-C70B1F9E2E32}

If it is there, it may be some other issue but it is probably missing. To resolve this you will usually run the installer that distributes this COM object. If you don't have one and you know what dll implements the object, you can run regsvr32.exe (or regasm.exe for a managed dll).

like image 128
csharptest.net Avatar answered Sep 22 '22 08:09

csharptest.net


I was running a C++ COM DLL from a Win Forms C# project on a 64-bit OS. I changed the Win Forms C# project to be x86, re-ran, and it worked. To do this:-

  1. Right-click the .NET project, and choose Properties
  2. Select the Build tab
  3. Set Platform target to x86
  4. Recompile, and re-run

Concept of changing bitness from George J's answer

like image 30
CJBS Avatar answered Sep 18 '22 08:09

CJBS


I am running some automated tests in Selenium and had same problem. Problem was solved by switching "Default Processor Architecture" to x86 in Test Settings.

like image 27
George J Avatar answered Sep 18 '22 08:09

George J


In my case the Class was registered properly.

But the Enable 32-bit Applications property of the IIS Application pool of the Application which uses the class was set to True. It was not finding it because the application was built in ANY CPU / 64 bit mode.

Setting Enable 32-bit Applications to False fixed the issue.

like image 37
Bhupinderjit Dhanoa Avatar answered Sep 19 '22 08:09

Bhupinderjit Dhanoa