Forcing a .net application compiled for Oracle 9 to use Oracle 11

by Kevin Goff 17. April 2010 00:58

To get a server installed with the Oracle 11 ODP.net client to run an application compiled using the Oracle 9 ODP.net client requires a configuration change.  Out of the box the 11 client will work with the an application compiled with the 10 ODP driver but there is no policy configured to work with ODP 9.  To make this work add a specific assembly binding configuration to your configuration file of choice (I prefer machine.config for my configuration).

 

Keep in mind this has to be placed in both the Framework and Framework64 machine.configs in order to make both 64 and 32 bit apps use the 11 driver. 

 

Here is is what I used:

 

  1. <runtime>
  2.   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  3.     <dependentAssembly>
  4.  
  5.       <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342"/>
  6.       <bindingRedirect oldVersion="9.2.0.401" newVersion="2.111.7.0"/>
  7.  
  8.     </dependentAssembly>
  9.   </assemblyBinding>
  10. </runtime>

 

 

Tags: , , ,

Diagnostics: x64, ODP.net and "Unable to find ... Data Provider"

by Kevin Goff 19. October 2009 21:53

Diagnostics: x64, ODP.net and "Unable to find ... Data Provider"

I came across a problem today on our x64 (extended 64 bit) servers when troubleshooting an Oracle installation. We completed the installation of the ODP.net Oracle client and setup as we normally do on our x86 machines but this time there was a problem: we weren't connecting to Oracle. I started diagnosing the problem using the typical techniques -- google the exception text. But -- no joy. There only 3 other articles that contained similar texts but none of them seemed to be pointing towards Oracle or x64. Now I knew I was in for some fun diagnosing.

Before I go to much further let me summarize the problem. First of all the error message, "Unable to find the requested .Net Framework Data Provider. It may not be installed.".

Next is the environment:

  • Running x64 machines in IIS 32bit mode.
  • We were using VS 2005, .net 2.0 runtime
  • ODP.net 10
  • Microsoft Enterprise Library - January 2006 version.

 

After trying several different typical fixes I realized I needed to start from scratch -- create a basic web app that hits oracle through ODP and see if it works. DING! The test project worked fine. So now what? Oracle works, IIS works, that pretty much leaves the Enterprise Library. After digging in to the guts of the how the Enterprise Library works I discovered that the installation process of the Oracle ODP client requires a little snip added to the machine.config. Further investigation found that Oracle did update the machine.config of the Framework64 directory but not the 32bit directory. AHA!

The solution: edit the machine.config (Located at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config) and add the missing piece. The Enterprise Library needs this piece to function. (the piece that was missing for our configuration is listed in blue below)

 

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
  1. ...
  2. <system.data>
  3.   <DbProviderFactories>
  4.     <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  5.     <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  6.     <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  7.     <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  8.     <add name="SQL Server CE Data Provider" invariant="Microsoft.SqlServerCe.Client" description=".NET Framework Data Provider for Microsoft SQL Server 2005 Mobile Edition" type="Microsoft.SqlServerCe.Client.SqlCeClientFactory, Microsoft.SqlServerCe.Client, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
  9.     <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342" />
  10.   </DbProviderFactories>
  11. </system.data>
  12. ...

 

Tags: , , ,

.NET Development

Windows x64 and ODP.net

by Kevin Goff 20. May 2008 00:15

Running an x64 (64 bit) version of Windows with Oracle ODP client can be a challenge to setup. If you need to run an x64 (64 bit) version of Windows with the Oracle ODP.net this is for you.

[NOTE: THIS INCLUDES INSTRUCTIONS FOR WORKING IN 32bit MODE ONLY]

IIS/ASP.net

If you need to run an x64 Windows machine with ASP.net using Oracle's ODP.net client you will want to run IIS in x86 (32 bit) mode. The reason for this is because, as of the writing of this article, Oracle has not yet published a production (non beta) release of the ODP.net client that runs in x64 mode. You can switch IIS to x86 mode using the instructions found here. You will also want to review this article if you are using the Microsoft Enterprise Library.

Console, Windows Forms, or Windows Services

.net will try and run in x64 bit mode by default. To force x86 mode you will need to switch the platform target from the default value of <Any CPU> to <x86> and recompile.

Another issue to be aware of is that any application that tries to make use of the either version of the Oracle client (x86 or x64) must NOT be installed in a path that contains parenthesis. That means anything installed under c:\program files (x86)\ will not work. Make sure to install these applications under some other directory such as c:\oraclestuff\.

References:

  • Oracle ODP Client installation for 32 bit mode usage
  • Oracle ODP Client installation for 64 bit mode usage
  • Working with x64 and the Microsoft Enterprise Library
  • Find other issues w/ ODP and x64? Shoot me a note using submit feedback

    Error messages and meanings:

    [BadImageFormatException: An attempt was made to load a program with an incorrect format.
    --Translation: you are trying to use a 32 bit ODP client while in 64 bit mode.

    Tags: , , ,