Use C # to connect to Oracle via oracle.dataaccess, you need to be aware of version issues when deploying

Source: Internet
Author: User

Usually we develop the use of 32-bit PC, so the installation is also ORACLE32-bit client. However, the general server is 64-bit, and the 64-bit Oracle client is installed, and you may encounter version problems if you are deploying an application that uses oracle.dataaccess to connect to Oracle.

There are two major version issues, one is the 32-bit version and 64-bit version of the problem, if we developed the application is 32-bit, then we must use 32-bit client, if 64-bit application of course corresponds to 64-bit client. It is important to note that using the VS development Web program in a 64-bit environment, the Web service "WebDev.WebServer.exe" that runs is 32-bit, so if you are debugging a 64-bit Oracle connector, it is best to deploy to IIS. Use IIS to connect to the Oracle database.

Another version issue is the oracle.dataaccess version number problem, my native is the 32-bit XP, installed ORACLE11GR2 client after the odp.net\bin\2 in the installation directory. The Oracle.DataAccess.dll file can be found in the X catalog and can be seen with the version number: 2.112.1.2. So I developed the program, the reference is also this version of the library.

However, under the 64-bit Oracle.DataAccess.dll is not the same, the installed version is 2.112.1.0, is windows2008x64 on the Oracle.DataAccess.dll.

Now the deployment of the development environment Program to the server will throw an exception

Failed to load file or assembly "oracle.dataaccess, version=2.112.1.2, culture=neutral, publickeytoken=89b483f429c47342" or one of its dependencies.

or a

Could not load file or assembly ' oracle.dataaccess, version=2.112.1.2, Culture=neutral, publickeytoken=89b483f429c47342 ' Or one of its dependencies. An attempt is made to load a program with an incorrect format and the like.

In short, the corresponding assembly cannot be found. Obviously, the system is looking for 2.112.1.2 Version of the oracle.dataaccess, and the server only 2.112.1.0 version, so the error, the solution is to modify in the Web. config, After the configsections node is finished, add the following:

<runtime>
    <assemblybinding xmlns= "Urn:schemas-microsoft-com:asm.v1" >
        <dependentAssembly>
             <assemblyidentity name= "oracle.dataaccess"
             publickeytoken= "89b483f429c47342"
             culture= "neutral"/>
             <bindingredirect
               oldversion= "2.112.1.2"
              newversion= "2.112.1.0"/>
        </dependentAssembly>
     </assemblyBinding>
</runtime>

This allows IIS to invoke 2.112.1.0 's oracle.dataaccess. This configuration is added and will work correctly.

Use C # to connect to Oracle via oracle.dataaccess, you need to be aware of version issues when deploying

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.