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,
Preliminary answer: my software was fine and something was wrong with the setup on that particular machine.
Edit
I just found out something that is probably the source of the problem. The problem machine has Office, but it is set up as click-to-run (runs off the internet) rather than MSI-based (runs from an EXE). This means that certain registry settings, DLLs, components, etc. are not available to Microsoft.Office.Interop.Excel
, so it fails.
Edit 2
That was definitely the problem. Just upgraded to a full MSI-based installation of Office, and everything works great.
Edit 3
Added this as a bug to Microsoft Connect:
https://connect.microsoft.com/VisualStudio/feedback/details/672276/excel-interop-fails-on-machine-where-office-is-installed-as-click-to-run#details