Question

A couple years ago I wrote a C#.NET program that used Microsoft ACE and JET OLEDB to convert Excel spreadsheets to CSV files. Recently we upgraded to a Windows Server 2008 x64 server. Since JET was deprecated that method no longer worked. Originally .xls files from Excel 2003 were handled with JET and .xlsx Excel 2007 files were handled with ACE. I changed the connection strings to use ACE for both.

We can now run the program successfully through a command prompt. However, when we use our automation software (which apparently runs the program similar to the Start->Run method), we get an error saying that the Microsoft Data Access Components are not installed. Upon researching these, it appears they only work on 32-bit systems and don't support anything above Windows Server 2000.

Any ideas? We have the newest beta x64 ACE OLEDB drivers installed. The program runs fine manually. I've also tried compiling the program with a target platform of x86. We also manually ran the program successfully using the windows account that the automation software uses.

Was it helpful?

Solution

On a 64-bit Windows, the process defines the bitness: 32 or 64.

If you start a program in 64-bit mode, and that program does COM (OLEDB is COM-based), it will look for COM 64 bits DLL only (in fact, it just uses the 64-bit side of the registry whe 64-bit COM components are registered).

If you start a program in 32-bit mode, and that program does COM, it will look for COM 32 bits DLL only.

Now, it can depend on the version of the C# compiler, but today, most C# program are configured to be compiled as "Any Cpu". It means they will run as 32 on a 32-bit OS and 64 on a 64-bit OS, which makes things quite complicated if they use COM directly or indirectly (sometimes, you don't even know you're using COM!).

So... to sum up:

1) determines the bitness of your process (easy with Task Manager, 32-bit processes on a 64-bit machine are suffixed with "*32").

2) install the corresponding COM OLEDB drivers.

If the OLEDB drivers do not exists in 64-bit mode, then you'll have to recompile your C# .EXE or patch it to force 32-bit mode. You can use the CORFLAGS tool for this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top