I have a C# WPF (.NET 4.0) application that uses Excel interop to read data from an Excel file.

When I run this app on my development machine, which has Excel 2007, it works fine. When I run it on another machine that has Excel 2010 installed on it, it fails with the following error message:

System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT:0x80040154 (REGDB_E_CLASSNOTREG)).

The failure occurs when attempting to create a Microsoft.Office.Interop.Excel.Application object, as in:

var app = new Application();

My project has a reference to Microsoft.Office.Interop.Excel.dll (version, runtime version v2.0.50727), which is located at:

C:Program FilesMicrosoft Visual Studio 10.0Visual Studio Tools for OfficePIAOffice14Microsoft.Office.Interop.Excel.dll

I tried to run the app with the default settings on the referenced dll:

  • Copy Local = False
  • Embed Interop Types = True
  • Specific Version = True

I also tried to run the app with the following settings on the referenced dll:

  • Copy Local = True
  • Embed Interop Types = False
  • Specific Version = True

But on the machine with Office 2010, neither of these attempts worked.

Other notes: The machine with Office 2010 is 64-bit w/ Windows 7. My development machine is X86 with Windows XP.


What is causing the “class not registered” exception and how do I fix it?


In response to Alex’s answer, I tried building the app as Any CPU, X86, and X64, but it made no difference. I’m still getting the same “class not registered” error.

Edit 2

Just tried the app on a 32-bit machine with Office 2010. No errors. So, it could be something wrong with the particular machine, or it could be the combination of 64-bit and Office 2010.

Edit 3

Okay, so now I’ve tested it on a different 64-bit machine with Office 2010. Again no errors. I think this means something is wrong with the particular machine and it’s not my software’s fault. Ahh programming.