VS established WinForm programs that connect to the Oracle database can run properly on the web but are not able to connect properly to run possible reasons (this article from Blog Park Deep Blue Habitat)

Source: Internet
Author: User

We usually use a 32-bit machine for development, loaded with 32-bit software, but our servers are generally 64-bit, so it is sometimes necessary to install a VS Debug program in 64-bit environment. One of the most recent problems was a colleague changing a computer with X64 Windows 2008 as the operating system and a 64-bit Oracle Client for the Oracle database connection. If the control application project or the WinForm project can connect to Oracle normally, but the Web project opens the Oracle connection in the program, the system throws an exception:

BadImageFormatException is raised when attempting to load the Oracle client library. This problem occurs if you are running in 64-bit mode with the 32-bit Oracle client component installed.

Obviously, this hint is incorrect because we have a 64-bit client, so there is no case that 64-bit programs call 32-bit clients. Is the generated program is 32-bit, and then 32 bits call the 64-bit client, so I changed the program properties in the build platform to X64,:

As a result, the generated WebService program still reports the same exception at the time of invocation. This problem has plagued me for a day, the solution is to uninstall the 64-bit client, install the 32-bit client in the X64 operating system, and then do so, but if it is not a Web application (such as a console application or WinForm program) but the same error, Then you will need to change the built-in platform to X86 in order to run the non-web app's project according to the Setup method.

Workaround:

This is certainly a compromise approach, and today finally found out the real reason for the original vs. building Web project, Usually run using the Webdev.webservier is a 32-bit service, so in which the Web project run, regardless of how to set the platform, can only be viewed as a 32-bit application, so when the Web project runs the connection 64-bit Oracle client will error, and not the Web project will not.

Search the Internet, as if the Wedev service does not seem to have 64 bits, so to solve this problem, then do not use this service as a Web service, and use IIS, because IIS is using W3WP, 64-bit operating system is 64-bit, Therefore, the 64-bit Oracle client can be used normally. The settings are as follows:

With this set up, each run will run as IIS, and the Oracle will connect properly, whether it is a Web project or a console application or a WinForm project.

"From the blog Garden Deep Blue Home, reproduced please indicate the author's source"

VS established WinForm programs that connect to the Oracle database can run properly on the web but are not able to connect properly to run possible reasons (this article from Blog Park Deep Blue Habitat)

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.