title: ODP.NET and OLEDB with Multiple Oracle Homes
body: <p>For legacy reasons, our .NET 4.0 application currently uses both the Oracle OLEDB and ODP.NET providers to connect to an Oracle instance.  We have standardized on the 11.2.0.3.0 Oracle client. Both data providers work as expected when one Oracle client is installed.</p>
  
  <p>Issues have been reported on computers that already had the 11.2.0.1.0 client installed.  A second client, 11.2.0.3.0, was installed for our application.  The installation looks like this:</p>
  
  <pre><code>c:\oracle
      \product
        \11.2.0
          \client_1      &lt;-- (existing) 11.2.0.1.0
            \bin         &lt;-- OraOLEDB11.dll registered here
            \network
              \admin     &lt;-- TNSNAMES does NOT contain ORACLESVR
          \client_2      &lt;-- (new) 11.2.0.3.0
            \bin  
            \network
              \admin     &lt;-- TNSNAMES contains ORACLESVR
  </code></pre>
  
  <p>Due to a <a href="https://community.oracle.com/thread/2367179" rel="nofollow">bug</a> in the 11.2.0.3.0 installer, the OLEDB driver is not registered in the second home, meaning the 11.2.0.1.0 driver remains registered.</p>
  
  <p>This leads to some interesting/odd behavior that I cannot explain:  </p>
  
  <ol>
  <li>if the "ODP.NET from 11.2.0.3.0" part of the application is used first, both providers can connect, meaning the "OLEDB from 11.2.0.1.0" is using the tnsnames.ora from the _2 home.</li>
  <li>if the "OLEDB from 11.2.0.1.0" part of the application is used first, neither provider will connect, presumably because both are using the tnsnames.ora from the _1 home.</li>
  </ol>
  
  <p>So, once the Oracle home is determined for the application, both clients attempt to use that home, causing complete success or complete failure. </p>
  
  <blockquote>
    <p>To work around this, we can do things like: register the 11.2.0.3.0 OLEDB provider, add the TNS_ADMIN environment variable, or add <code>ORACLESVR</code> the tnsnames.ora from the _1 home.</p>
  </blockquote>
  
  <p>However, I want to know <strong>WHY</strong> this is happening?  I cannot find, in the Oracle documentation for each provider, how the tnsnames.ora file is located when two clients are present and TNS_ADMIN is not specified.  </p>
  
  <p>How does one provider affect the other?</p>