1

I am using ODP.NET in order to connect to Oracle database from my application. I would like to use Entity Framework and built application in x64 mode, but I am not quite sure how does the x86/x64 version selection of ODP.NET works.

As you need to have 32-bit Oracle Dev Tools for Visual Studio installed in order to have EF design-time tools available, I installed both x64 and x86 version.I have installed clients to separate folders. My question is: Is Entity Framework able to automatically select right version of ODP.NET based on build settings?

marek_lani
  • 3,895
  • 4
  • 29
  • 50
  • As far as I remember, NO. I always had manually include the correct version of ODP.NET – Fabio Dec 30 '15 at 12:20
  • Thanks @FabioLuz , but I found this on the oracle sites: it is not necessary to reference ODP.NET namespaces as ODP.NET is being used indirectly via Entity Framework. So do I have to somehow override it? – marek_lani Dec 30 '15 at 14:25
  • 3
    Oracle works in interesting way. They provide 32bit client and 64bit client. Each comes with its specific version of Oracle.DataAccess.Dll. These DLLs are identical in every way besides architecture they built for - use `corflags oracle.dataaccess.dll` to see. So, you should be able to drop one or another into output folder. When you build your app - it doesn't matter, which one is there. It only counts at runtime. So, what you can do is create pre-build or post-build action, in which you copy right dll version based on build config. Careful-orace checks these in GAC, i think. Unregister them – T.S. Dec 30 '15 at 15:10

1 Answers1

2

If you run a 64-bit application, i.e. your compile target is "x64" then you must load also the 64-bit version of ODP.NET (and also all other 64-bit Oracle Client files). Same applies for 32-bit version respectively. When ODP.NET is registered in GAC then this selection works automatically. However, apart from Oracle.DataAccess.dll the application has to load also other DLL's. They are searched according your PATH variable, i.e. if your PATH first contains the "wrong" Oracle folder you will get the famous "The provider is not compatible with the version of Oracle client" error.

When you install your 32-bit and 64-bit Oracle Client (and ODP.NET providers) according this instruction BadImageFormatException. This will occur when running in 64 bit mode with the 32 bit Oracle client components installed it should work well.

Community
  • 1
  • 1
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110