Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I would like to know how to determine if the Ace OLEDB Driver is 32 or 64bit installed on the target PC and then tailor the 32 or 64 bit build of my program which writes to excel with OLEDB.

Currently on 64 bit office with 64bit ACE I need to change the configuration in visual studio from x86 to x64 and vice versa.

Is there any method to detect 32/64bit installation and do you need in the setup project to write a script or can you dynamically write code to alter the 32/64 build that way.

Thanks,

Jase
Posted
Updated 21-Jul-12 12:59pm
v2
Comments
Sergey Alexandrovich Kryukov 15-Jul-12 1:10am    
Not clear. It looks like you think interop is the alternative to threading, but they are not related. Could you create some complete but short code sample? If you could, use "Improve question".
--SA
AU Jase 15-Jul-12 1:38am    
some pseudo code:

[list : aa,bb,cc]
[DATA TABLE : COLUMNS aa,bb,cc, etc with rows 0--n]
I want to write list(n) spreadsheeets based on for (0) column AA of datatable,etc
so I do in a loop
WRITE DATA TO EXCEL (FROM LIST) , Create Excel Interop/OLEDB , etc
WRITE TO EXCEL data in datatable based on LIST column criteria
DISPOSE EXCEL INTEROP/OLEDB, etc
then loop

and all the above is in a function call within a backgroundworker thread

i get issues with empty datatable, row in datatable deleted exceptions

1 solution

If you compile your app to target "Any CPU" it'll run 32-bit on 32-bit procs and 64-bit on 64-bit procs.

If you compile your app to target "x86", it'll run 32-bit only no matter what O/S it's running on.

But, if you compile "Any CPU", since you can't combine 32- and 64-bit code in the same process it's kind of pointless to check to see what's installed. You should, though, be checking to see what bitness your code is running as. That's easy enough to do by checking the sizeof an IntPtr. It'll be 4 bytes wide if your code is running 32-bit and 8 bytes if 64-bit. Then it's just using the correct connection string.

Again, you don't check what Office or driver is installed, you check what your code is running as.
 
Share this answer
 
Comments
AU Jase 21-Jul-12 20:14pm    
Hi Dave,

I see where you are coming from, but this is the problem I am thinking about:

1. You have 32 bit Ace Excel OLEDB 12.0 driver installed, yet you have a 64bit binary of the program in c# (incompatible) on win 7 x64. so you have a problem
(by virtue of installing 32 instead of 64bit office 2010)

In order to solve this issue you will need the x86 build.

So do you:

In the setup project (installer) configure it to check and then copy the relevant x86 or x64 prebuilt binaries across ?

or do you have a routine in your code to check and tell configuation manager to compile the appopriate build ?

The reason for asking is : x64 build using OLEDB 12.0 will fail if using 32bit installed OLEDB (office 2010) and vice versa

the connection string is generic for either 32/64 bitness, is it decided by the exe build and not the connecting string ? on a 64bit exe, with a 32bit installed drivers, I need to manually change to 32bit to get it to work, and if I was using 64bit drivers with 32bit exe I need to change it to 64bit to get it to work, regardless the connection string stays the same

else I get ISAM, ACE, OLEDB exceptions
Dave Kreskowiak 21-Jul-12 22:22pm    
You're going about this the wrong way.

This problem is solved at install time, not run time. If you install the appropriate runtime, found at http://www.microsoft.com/en-us/download/details.aspx?id=13255, you don't have to worry about Office being installed at all and your app would still have everything it needs to work.

AU Jase 21-Jul-12 20:17pm    
could you probe the installed Office 2010 OLEDB registry entry to see if its 64 or 32 bit and use it as a conditional exe to run either the 32 or 64bit version of your source exe ? If so , how would this be achieved ?
AU Jase 21-Jul-12 23:55pm    
I understand that, just how do we know if 32 or 64bit office is installed so the appropriate binary is used, cannot use 64bit exe if 32bit access oledb is on target machine, if x64 OS no guarantees 64bit access oledb is installed !

Just covering all bases
AU Jase 21-Jul-12 23:56pm    
Tried you int detection if left on default config it's 64bit on 64bit OS as expected but my office is 32bit so it still fails

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900