System.data.OracleClient with 32 bits oracle client driver on Seven 64 bits Operating system

守給你的承諾、 提交于 2019-12-13 00:35:59

问题


I have a Web application migrating from asp.net 1.1 (VS 2003) to Asp.net 2 ( VS 2008). I have a problem to execute Oracle connexion on the new version . The dev environnement is 64 bits Seven. When generate application with all CPU , i have a probleme on System.Data.OracleClient, exception System.BadImageFormatException: Tentative de chargement d’un programme de format incorrect. (Exception de HRESULT : 0x8007000B). . I generate on x86 CPU and i have this error on start :

[BadImageFormatException: Impossible de charger le fichier ou l'assembly 'CpimWebApplication' ou une de ses dépendances. Tentative de chargement d’un programme de format incorrect.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190

Whats the problem ? The Oracle Client on machine is 32 bits version . I have read on web that it s not possible to utilise System.data.OracleClient with 32 bits oracle Client ? Instal 64 bits Oracle client is the solution ? TIA Regards


回答1:


If you are running your application in 64 bits mode you cannot use the 32 bits Oracle driver.

You need to either install the 64 bits Oracle driver and run your application in 64 bits mode,

or

set the application to run in 32 bits mode. You can do that in IIS by choosing your application pool, go to Advanced settings and set "Enable 32-bit applications" to true.




回答2:


GTG is right.

However, System.Data.OracleClient is deprecated. Microsoft is not supporting it anymore.

So, I would recommend you using Oracle Data Provider for .Net: ODP.Net.

You can download it from:

Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (32-bit) Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64)

For development(Win7 64-bit), use 32-bit flavor. I've tried 64-bit Oracle client with no success. For production(Wind2008R2 64-bit), use 64-bit flavor. Note that they must be the same version (11.2.1.0).

Also, make sure you compile your app for "Any CPU", adding the reference to Oracle.DataAccess, setting "Specific version" to "True" and "Local copy" to "False". By doing this, when you deploy your app to production environment, it will look for the same version (11.2.1.0, 64-bit equivalent), from the GAC.



来源:https://stackoverflow.com/questions/8433803/system-data-oracleclient-with-32-bits-oracle-client-driver-on-seven-64-bits-oper

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