Trying to not need two separate solutions for x86 and x64 program

后端 未结 5 1469
北恋
北恋 2021-01-02 15:45

I have a program which needs to function in both an x86 and an x64 environment. It is using Oracle\'s ODBC drivers. I have a reference to Oracle.DataAccess.DLL. This DLL is

5条回答
  •  再見小時候
    2021-01-02 16:10

    This is purely a deployment problem, you should never have to maintain different projects. It is an awkward one though, and boo on Oracle for not taking care of this themselves. Another consideration is that this assembly really should be ngen-ed on the target machine. Some options

    • Create two installers, one for x64 and one for x86. The customer picks the right one, based on the operating system she uses. Simple enough, you just copy the right file.
    • Deploy both assemblies to the GAC. Now it is automatic, .NET picks the right one on either type of machine. Big companies should almost always use the GAC so they can deploy security updates, not sure why Oracle doesn't do this.
    • Deploy the assemblies to a x86 and x64 subdirectory of the install directory. You'll need to write an AppDomain.AssemblyResolve event handler that, based on the value of IntPtr.Size, picks the right directory.
    • Change the target platform on your EXE project to x86. Given that your code needs to work on a 32-bit machine as well as on a 64-bit machine, there isn't/shouldn't be a reason to build for AnyCPU.

提交回复
热议问题