In a 64-bit environment, when using VS to establish a Web project for Oracle connection, you must note that WebDev is a 32-bit

Source: Internet
Author: User

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.

Solution:

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.

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