We've discovered that if we read from an Excel file using the Microsoft.ACE OLEDB provider from a 64-bit machine with a 32-bit version of Office installed, it will throw an exception if built for platform "AnyCPU".
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
The solutions posted here all seem to be about changing your build platform to x86, or installing 64-bit data access components on the user's machine, neither of which are an ideal solution for us.
Is there any other way via the c# code to ensure that it reads the 32-bit version of the OLEDB data provider?
Example code :
string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\test.xlsx;Extended Properties=Excel 8.0;";
using(OleDbConnection connection = new OleDbConnection(connString))
{
connection.Open(); // exception here
}