Solution for. Net Access to Oracle in Windows 64-bit environment

Source: Internet
Author: User
Tags oracle developer

Currently, Windows operating systems can be divided into two categories: 32-bit and 64-bit (64-bit also distinguishes x86_64-bit and itanium), and Oracle clients are also differentiated.

Some problems often occur during installation and development. This article summarizes the related solutions.

Oracle Instant Client


All the instructions below are based on Windows 64-bit (taking windows as an example)

1 solution (this is the final step, and others are for reference)

1 install the oracle64-bit client (win64_11gr2_client ):

Download Page:





Downloaded to \ \ common software \ oracle \


Then install the SDK properly and configure database connection, such as tnsnames. ora.


2. Add the network service user to the administraotr group and restart the computer (important)

3. Create an website. Set the debugging mode of the program to IIS instead of webserver.

4 because WebServer is a 32-bit program, if you want to use webserver for debugging, you can consider installing a 32-bit Oracle client (not tested ).

Note: If the 32-bit Oracle client has been installed, this test is not performed.

2 installation sequence

Install Oracle 11g Release 2 odac with Oracle Developer Tools for Visual Studio, configure the server tnsnames, and use sqlplus to test the connection.

Start IIS, publish. NET applications connected to Oracle, and test the application. The error "system. Data. oracleclient requires Oracle client software 8.1.7 or later" is reported. Solution: Assign read and execution permissions to the Oracle installation directory as the network service user and pass them to all subdirectories.

Restart IIS and report "badimageformatexception is thrown when an Oracle client library is loaded. This problem occurs when the 32-bit Oracle client component is installed in 64-Bit mode. Solution: Download and decompress the x64 version of instantclient_11_2, put it in the Oracle installation directory, and search in the path before.

Restart IIS and report the "ORA-12154: TNS: cocould not resolve the connect identifier specified" error. Solution: Specify the environment variable tns_admin to the directory where tnsnames. ora is located.

Restart IIS and the. NET application successfully connects to the database server.


3. In, you do not need to use webdev for debugging. You must use IIS for debugging.

We usually use 32-bit machines for development and install 32-bit software, but our servers are generally 64-bit, so sometimes a vs debugging program needs to be installed in a 64-bit environment. Recently, a problem occurs when a colleague changes his computer and uses x64 windows 2008 as the operating system to connect to the Oracle database, therefore, a 64-bit Oracle client is installed. If the application project is controlled or the winform project can connect to Oracle normally, but when the WEB Project opens the Oracle connection in the program, the system throws an exception:

Badimageformatexception is thrown when you try to load the Oracle client library. This problem occurs when the 32-bit Oracle client component is installed in 64-Bit mode.

Obviously, this prompt is incorrect, because we have installed a 64-bit client, so there is no situation where a 64-bit program calls a 32-bit client. Is the generated program 32-bit, and then 32-bit calls the 64-bit client, so I changed the generate platform in the program attribute to x64 ,:

As a result, the generated WebService program still reports the same exception during the call. This problem has plagued me for a day. The solution was to uninstall the 64-bit client, install a 32-bit client in the x64 operating system, and then, however, if no web application (such as a console application or winform program) reports the same error, you need to set the non-web application project according to the following method, change the generated platform to x86 for normal operation.


This is of course a compromise. Today, we finally found the real cause. Originally, when vs was creating a web project, it usually used its own webdev. webservier is a 32-bit service. Therefore, any web project running in it can be viewed only as a 32-bit application no matter how platform is set, therefore, when a web project is running, an error is reported when the 64-bit Oracle client is connected, instead of a web project.

I searched the internet and it seems that wedev does not have 64-bit services. To solve this problem, I should not use this service as a web service, but use IIS because IIS uses w3wp, the 64-bit operating system is 64-bit, so the 64-bit Oracle client can be used normally. The specific settings are as follows:



After this setting, it is good to run with IIS each time. Whether it is a web project, a console application project, or a winform project, it will connect to Oracle normally.


4. Serious Oracle program development problems with

Oracle-based development
Data Connection Failed. Check whether the database has started and the badimageformatexception is thrown when the Oracle client is loaded. if the 32-bit Oracle client component is installed and runs in 64-Bit mode, this problem occurs.

The problem in English is:
"Attempt to load Oracle client libraries threw badimageformatexception. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed"

The specific environment is:

Win2008 64

Vs 2010

There is no problem in the development and debugging process, and the problem of deployment comes.

After a lot of changes, the result after 64-bit client modification is:

There is no problem in IIS testing, and this problem comes as soon as you debug it.

The most strange thing is that both errors share the same error message.

Well, I met both of them, so I solved them together.

I spent two days solving the problem. I have some related information on the Internet, but it is not complete. The specific cause is unknown. I will give a full explanation below.



Vs compiler debugging uses the above process instead of IIS for release. We can see that it is obviously a 32-bit. The IIS 7 process w3wp is 64 bit. This shows that if we are debugging, our program is simulating 32-bit running. After the deployment, it is indeed simulating 64-bit running, what I cannot understand most is why one is simulating 32-bit running, the other is simulating 64-bit running, and the exception information given to us is indeed the same? No matter how much it is, at least now we can draw a conclusion:

If the program debugging process you write has no problems, you will have problems when publishing it to 64-bit IIS, and vice versa.
The solution is as follows:

Case 1: No problems occurred during the debugging and problems occurred during the release.

If debugging has no problem, you must use the 32-bit Oracle client, and the IIS on the server is 64-bit. Therefore, if you need to publish a website, you must install the 64-bit client.

In fact, system. Data. oracleclient points to OCI. dll under the path environment variable. Therefore, we only need to allow the program to find the 64-bit OCI. dll. The method is as follows:

1. Download, and decompress it, such as c: \ instantclient-basic-win-x86-64-11.1 \ instantclient_11_1 (this part is also required, according to the actual situation of different modifications ).

2. Add the above path to the system environment variable path.

Then restart the Operating System (this is required. I did not do a good job in the afternoon and it will be done immediately after the restart). The program will search for OCI Based on the path. DLL, if you encounter a 32-bit OCI. the dll will automatically skip and find the 64-bit OCI. DLL to connect to the database.

Case 2. problems occurred during the debugging process, but there was no problem in testing IIS

If there is no problem in IIS testing, you must use 64-bit Oracle client. The debugging error is because the webdev process server to be debugged is 32bit. to simulate the real environment, you need to make some settings.

If so, change the debugging server of Vs to IIS.


Here, we can conclude that the exception information given by Oracle is correct for the first case and incorrect for the second case, which means the opposite !!! It may be a careless mistake of localization personnel.

After this problem is solved, the test and Development of custom Oracle membership for Sharepoint will be completed. We will also record an article about the Development Summary of custom Oracle membership for Sharepoint in the near future.


5 system. Data. oracleclient requires Oracle client software 8.1.7 or later.

When using vsts2005/2008 + oracle9 for environment connection to Oracle, The vs development server runs normally, but the IIS server reports an error during debugging and deployment!

IIS server error: system. Data. oracleclient requires Oracle client software 8.1.7 or later.


Cause of error:

1. Although it is reported that the Client Version 8.1.7 and later must be installed, the. NET account does not have the permission to access the Oracle/bin folder.

2. Advanced Access Security is provided in the NTFS system of Windows Server 2003/2008. FAT32 may not have this problem.


The solution is as follows:

Windows Server 2008 is the same for Windows Server 2003.

1. Open a computer with an Oracle client installed, right-click the installation directory c: \ oracle \ ora90 \ bin, and choose Security tab> Edit> Add.

2. click "search range" and select "ntwork service" in the account shown below-Grant "read and execute" permissions to him (if not, give him full control, this is not safe), the sub-Folder inherits this permission, OK.

3. Open "Server Manager"-"configuration"-"local user and group-" group-"adminisgrators-" to add the network service

4. Restart IIS and enter "iisreset" in "run ".



Related Article

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: 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.