Jet OleDB 4.0 provider not registered on the local computer

I have a C# WinForms program that attempts to import some data from Excel into a SQL Server database using the Ole DB provider. Today the import suddenly failed with an error message saying that the Jet Ole DB provider was not registered on the local computer.

InvalidOperationException: Jet OleDB 4.0 provider not registered on the local computer

Well, I was pretty sure that it was. So what was wrong then?

Turned out that the Configuration Manager accidentally got reset to “Any CPU” setting. I have an x64 machine on which that leads to running the application in 64-bit mode, in which there is indeed no Jet OleDB provider available (and no Edit-and-Continue either, among other things…).

Setting the target platform to compile to x86 immediately solved the problem.