How to Make ODP.NET 4.0 (64 bit) working on 64 bit machine Windows 7?

核能气质少年 提交于 2019-12-09 07:04:57

问题


I have installed the Oracle Client for the 64 bit machine using the XCopy 11.2 provided by Oracle (Installed everything as per the read me instructions).

I am using Visual Studio 2010 and the project is of type ASP.NET Website.

When I tried to execute my ASP.NET Website using the Oracle Connection installed above..it is giving me the error from the web.config file during compile time.

**

"Could not load file or assembly 'Oracle.DataAccess, Version=4.112.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified"

**

It worked if I changed the value of Enable 32-Bit Applications to True in IIS App pool.

But my requirement is to make it work on 64 bit machine with 64 bit ODP.NET connector, So I do not want to change the value of Enable 32-Bit Applications to True.

So, If you could please help me finding an answer that would be greatly appreciated. Please help me fixing the above error.


回答1:


The best possibility to handle this is to use the x86 version locally with Visual Studio and x64 version on the server with IIS. To do this you have to download both versions - copy one in folder lib\x86 and the other in lib\x64 After this you have to modify the project file(s) - visual studio supports conditional references. Add following section to your project file:

<PropertyGroup>
     <ReferencesPath Condition=" '$(Platform)' == 'x86' ">..\Lib\x86</ReferencesPath>
     <ReferencesPath Condition=" '$(Platform)' == 'x64' ">..\Lib\x64</ReferencesPath>
</PropertyGroup>

After this reference the odp.net assmebly like this:

<Reference ... processorArchitecture=$(Platform)">
   <SpecificVersion>False</SpecificVersion>
   <HintPath>$(ReferencesPath)\Oracle.DataAccess.dll</HintPath>
   <Private>True</Private>
</Reference>

This way when you can build locally as x86 and on the server x64 and always the correct version of Oracle.DataAccess.dll will be referenced.

Alternatively if you only want to use the x64 version than you have to stick to IIS even you work locally OR you could try to run the open source version of Cassini in x64 mode (http://cassinidev.codeplex.com).

For me the best possibility is to reference both versions as described above - this has been working fine for everyone on my team for a while now.




回答2:


You must install 64-bit Oracle Data Access Components (ODAC) since the Oracle Client Installation doesn't register Oracle.DataAccess.dll into the assembly.

If your oracle data access installation is OK, everything should work after unchecking "Enable 32 bit applications" in your Application Pool settings.

If you still have the same error, it is possible that you have a 32 bit dll in your bin folder of the website. Just delete it and the website will use the 64 bit from the assembly and it should work.



来源:https://stackoverflow.com/questions/6272190/how-to-make-odp-net-4-0-64-bit-working-on-64-bit-machine-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!