none
How can I build a C# app that will talk to Office 32-bit and Office 64-bit? RRS feed

  • Question

  • There are various confusing discussions of this topic so I want to ask the simple question -

    "How can I build a single C# app that will talk to Office 32-bit and Office 64-bit?"

    Setting CPU=ANY does NOT help because if you build CPU=ANY it runs 64-bit on an x64 machine so will not talk to 32-bit Office without the AccessDatabaseEngine_x64 drivers, and if you install the x64 drivers using /passive, Office starts doing weird things. You have to set the /32preferred flag (or whatever it is) and there is no preferred about it since now it always runs 32 bit and won't work on a different x64 machine that has 64-bit Office and the 64-bit drivers. Catch-22 - MSFT did not think this one through. Basically, there is no way to build one C# app that will even run on x64 machines, much less x86 and x64 machines, where one machine has Office 32-bit and another Office 64-bit, w/o Office reconfiguring Word and Excel every invocation, or Outlook able to create new sub folders, or being able to log in to LIVE. Please tell me I'm wrong!

    This isn't even for a commercial deployment.  My boss did not read the caveat to use 32 bit Office, I did, we both run Win7 x64, and neither of us wants to re-install the other version of Office, that being so much fun...

    - Dave


    Dave



    • Edited by Dave Kolb Wednesday, February 13, 2013 3:55 AM
    Wednesday, February 13, 2013 3:52 AM

Answers

All replies

  • See my last answer in the below forum thread. Essentially you can have one version of the app, but two different deployments. One for 32-bit (x86) and one for 64-bit (x64).

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/abf34eea-1029-429a-b88e-4671bffcee76


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, February 13, 2013 1:54 PM
  • Well maybe you don't see this as an issue, but other people do -

    #1 There is no way to build an x86 and x64 binary at the same time other than a tedious manual process that modifies the solution back and forth.

    #2 There is no way to have a WIX installer install an x86 or x64 version based on the version of Office installed.

    #3 This wastes the concept of CPU=ANY.

    There are lots of issues and problems I'm sure MSFT had no intention of supporting which does not mean they shouldn't when it is a PITA for their users. The Configuration Manger (thx for telling me there was one) does not have a choice that says "build me two assemblies so that my app can work with either version of Office". And furthermore, the x64/ANY app will work with the x64 driver and the 32-bit Office data but breaks Office itself so this COULD be made to work, but the real answer is apparently MSFT does not WANT to bother to make it work, all intentions aside.



    Dave

    Wednesday, February 13, 2013 3:41 PM
  • In answer to question #1, it's a single option that you have to change before compiling. That's it. There are even separate folders for the resulting assemblies.

    With respect to #2, my thought was that you would have two different installation packages and not one that determines which version to install. In any event, I have to think that Wix has sophisticated enough tools (e.g. a scripting language) to identify which version of Office is installed, so theoretically you can do it with one. I can do it with Inno Setup and that tool is free.

    As far as #3 is concerned, yes this is true, but we're not talking about a native .NET library for Access. If it was up to me one would be included, since it is the mostly commonly used file based data store, and this would eliminate the deployment problem. But, the decisions regarding the OLEDB providers for Microsoft Access are up to the Microsoft Office folks and not those who work on .NET.

    BTW, there is an Access for Developers forum that you may want to post to. You're liable to receive similar answers, but at least they're more likely to hear you.

    http://social.msdn.microsoft.com/Forums/en-US/accessdev/threads


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, February 13, 2013 7:42 PM
  • Paul, this apparently CAN be done so MSFT should support it. Thanks to the answer from "Applied Maths NV" in the forum post you mentioned earlier -
    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/abf34eea-1029-429a-b88e-4671bffcee76

    • Marked as answer by Dave Kolb Thursday, February 21, 2013 4:52 PM
    • Edited by Dave Kolb Thursday, February 21, 2013 4:55 PM
    Thursday, February 21, 2013 4:52 PM