Oracle.DataAccess mismatch error

后端 未结 3 1967
青春惊慌失措
青春惊慌失措 2021-02-14 23:58

I installed the odp.net 32 bit installation for Visual Studio 2012. I set a reference to the Oracle.DataAccess.dll and my connection to Oracle seems to be working.

When

相关标签:
3条回答
  • 2021-02-15 00:04

    This is only a vs.net warning however is there any way to get rid of this?

    I believe there is no way to get rid of that, since you want to deploy on 32 bit machine and you create on 64 bit. This is just a warning that informs you that there may be sth wrong with the driver. Nothing to worry about if you now what you're doing.

    You should expect it - you use 32 bit libraries on 64 bit architecture.

    0 讨论(0)
  • 2021-02-15 00:06

    Another solution:

    Download ODAC 11.2 Release 5 (11.2.0.3.20) and set your compiler to x86. I am 100 % sure it will clean all warnings related to oracle. Set namespace to: using System.Data.Odbc;

    Then make a database connection.

    0 讨论(0)
  • 2021-02-15 00:19

    Like you said, it's just a warning. Because ODP.net is not "AnyCPU" the warning indicates that you have a dependency that is not going to adapt to the host operating system as your own application is. As long as your odp.net install matches the os in terms of bits, you'll be fine. But the compiler is unable to make that determination and is trying to give you a heads up.

    I did find a connect article on this which includes a possible change (i'm assuming to the proj file) to disable the error:

    <PropertyGroup>
    <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
    </PropertyGroup>
    

    In any case, your "AnyCPU" application will run fine on your server as long as the 32 bit odp.net you install on the server is the same version as the 64 bit odp.net you referenced (or publisher policies are properly installed to redirect to a later version). To eliminate any confusion i generally set "Copy Local" for the reference to "false." In otherwords, I compile against a specific version of the dll but let it run against what it resolves from the GAC (which includes publisher policies that most of the odp.net installations include).

    You can also install the 32 bit odp.net on your dev machine (ideally the same version again) in order to run/debug 32 bit applications or to use the integrated tooling that comes "with Oracle Developer Tools for Visual Studio" inside of Visual Studio.

    All that said, there's more than meets the eye here. If you're application is in fact running (which is implied with "it's only a warning"), as 64 bit, than it is NOT using your 32 bit installation. I would guess your machine already has the 64 bit version installed (multiple oracle homes).

    0 讨论(0)
提交回复
热议问题