0

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.

Tony Trozzo
  • 1,231
  • 6
  • 20
  • 34

1 Answers1

1

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.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • Thanks for the help. We tried changing the target platform and that definitely changed the way the oledb drivers worked. However, our automation program still seems to be throwing MDAC errors no matter which it runs. It doesn't appear like it's giving the program control. – Tony Trozzo Dec 02 '10 at 22:21
  • If its now throwing different errors, than you progressed somehow, and now it's a different problem. – Simon Mourier Dec 02 '10 at 22:31
  • Correct. It looks like our automation software is trying to use MDAC for some crazy reason. MDAC doesn't even support x64 servers. – Tony Trozzo Dec 02 '10 at 22:33
  • Looks like MDAC was used, and the problem ended up being a combination of your solution and the fact that our path was missing a %CommonProgramFiles(x86)% variable. Thanks again! – Tony Trozzo Dec 03 '10 at 16:08