Fix Excel COM Interface Cast Errors in .NET Framework x64 Builds
Question details
Users experience a COM interface cast error when running a .NET Framework 4.7.2 application built for x64 utilizing Microsoft.Office.Interop.Excel with Office 2021.
- Product
- Microsoft Excel 2021 / .NET Framework 4.7.2
- Device & OS
- not provided
- Scenario
- Developing and compiling a .NET Framework application targeting the x64 architecture and interacting with Excel via COM interop.
- Observed behavior
- The application throws a COM interface cast error specifically on x64 builds, while x86 or Any CPU configurations function properly.
Verify your project's build configuration settings in Visual Studio and ensure all Microsoft.Office.Interop.Excel assembly references are up to date.
Repair the Microsoft Office Installation
Running a repair on Microsoft Office 2021 often resolves broken 64-bit COM interoperability registry keys that cause cast errors.
COM interface cast errors on specific architectures usually stem from corrupted or missing registry configurations for the Office installation rather than your code.
Navigate to the Windows Control Panel or open the Settings app and go to 'Apps & features' (or 'Installed apps').
Scroll through the list of installed programs, locate Microsoft Office 2021, and select 'Modify' or 'Change'.
Choose the 'Quick Repair' option and follow the on-screen prompts. If the issue persists after completion, try the 'Online Repair' option.
Create a Microsoft 365 Support Ticket
If repairing Office does not resolve the platform-specific build issue, you will need to escalate it to the appropriate Microsoft development team.
Discover WPS Office as a Lightweight Alternative
Experiencing stubborn COM interop issues and registry errors with Microsoft Excel? Consider switching to WPS Office, a highly compatible, fast, and free alternative that handles all your standard spreadsheet tasks without the heavy registry footprint.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package.
- 2. Install WPS Office: Run the downloaded executable file and follow the quick setup wizard.
- 3. Open Your Spreadsheets: Launch WPS Spreadsheets and effortlessly open your existing Excel documents.

Frequently Asked Questions
Why does the Excel COM interface cast error only happen on x64 builds?
This typically occurs due to mismatched, unregistered, or corrupted 64-bit registry keys for Microsoft.Office.Interop.Excel on the host machine, while the 32-bit (x86) keys remain intact and functional.
What does the Prefer32Bit setting do in .NET Framework?
The 'Prefer32Bit' flag forces an 'Any CPU' application to run as a 32-bit process on 64-bit systems. This often inadvertently bypasses 64-bit COM interop errors by utilizing the functioning x86 Office registry paths.
Can reinstalling the Microsoft.Office.Interop.Excel NuGet package fix this?
Usually, no. If the issue stems from a corrupted local Office installation registry, updating or reinstalling the NuGet package will not resolve it. Repairing the actual Microsoft Office application is required.




