So I wrote a method in my company's product a year and a half ago that makes use of Excel 2007's COM automation to export data, only now I'm finding that it's no longer working on machines in the office.
I tested the functionality of the method on my own machine and got the same result.
Digging deeper, I found that when I get as far as
var excel = Excel.Application
If I add a watch on the excel object, I see that every property throws a cast exception.
After doing some research, I saw something about registry keys that can interfere with automation. I managed to dig through and delete a registry key:
HKEY_CLASSES_ROOT\TypeLib{00020813-0000-0000-C000-000000000046}\1.7
With the following string value defined within:
"PrimaryInteropAssemblyName"="Microsoft.Office.Interop.Excel, Version=14.0.0.0
I then ran the same piece of code again, only this time it ran perfectly fine.
Other machines in the office I've tested the application on have had the same error, only I haven't been able to fix them in the same way.
Has anyone else encountered this before?
Thanks