System.Data.OracleClient on Windows 2008 x64

文章详细介绍了在Windows 2008 x64系统上安装和配置Oracle客户端软件遇到的问题及解决方案,包括安装不同版本的Oracle客户端以及设置PATH环境变量以确保正确连接Oracle数据库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

System.Data.OracleClient on Windows 2008 x64

自從家中與公司的機器分別改用Vista x64及Windows 2008 x64後,在享受爽快揮霍記憶體之餘,也一併開始體驗在新大陸拓荒的感覺。大部分的高階應用程式,多半可以x86虛擬環境執行,問題不大。但有不少涉及低階處理的程式選擇頓時劇減,例如: RamDisk因為Driver未具備簽章無法使用、能支援x64的免費防毒軟體屈指可數、之前提到重新Survey了DVD燒錄程式...

這些軟體上的短缺咬一咬牙就撐過了,最讓我痛苦的是原本部門大家慣用的ODP.NET 9207完全不支援x64版本,安裝程式根本沒法跑!

Google之後,知道Oracle 10.2g開始Support Vista/Windows 2008 x64,但無奈ORACLE網站不知怎麼,連續好幾天,下載連結都出現HTTP 404。最後終於在兩週後讓我下載到近500M的10204_vista_w2k8_x64_production_client.zip,安裝完成馬上用現有的專案試了一下,結果出現:

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.

檢視權限等OK,試了一下重新開機,訊息變了:

System.InvalidOperationException: 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. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).

似乎是DLL版本不對,但我明明裝的是64bit Oracle Client,.NET程式限定Build for x86 CPU,為什麼跟我說: 在64 Mode下去讀了32bit Oracle Client? 感覺上恰恰相反才對。

反覆測試,忽然發現如果設定Build for AnyCPU或x64就可以順利連上Oracle,唯獨設成x86時會出現上述疑似相反的錯誤。設成x86時去讀取64bit Oracle Client DLL會發生問題,十分合理,只是一開始的錯誤訊息讓我有些迷惑。如果這是問題,那麼是否同時再裝32bit Oracle Client就好? 但,System.Data.OracleClient要如何知道該用32bit或64bit Oracle Client? 我每次都要改Registry或設PATH環境變數來切換使用的Client嗎? 一切的疑問,都要試了才知道!!

找到10203_vista_w2k8_x86_production_client.zip,裝在另一個目錄下(c:\oracle\ora10g vs c:\oracle\ora10g_x86),重新登入讓PATH環境變數中的c:\oracle\oar10g_x86\bin生效,x86就可以跑了。抱著期待的心情切成x64再跑,Yes! 也成功了!! 但這是x64 .NET用32bit Oracle Client的結果嗎?

使用Process Monitor解開了疑惑: System.Data.OracleClient會沿著PATH環境變數的路徑去找oci.dll,在x64下會略過c:\oracle\ora10g_x86\bin\oci.dll,找到c:\oracle\ora10g\bin\oci.dll後連線;x86時則是找到c:\oracle\ora10g_x86\bin\oci.dll就結束尋找,AnyCPU則與x64的行為相同。
(記得之前的PB6連Oracle9嗎? 一樣是用PATH法)

換句話說,OracleClient會依x64/x86決定適當的Oracle Client版本,不必勞煩我去手工切換。因此,如果想在Windows 2008/Vista x64上使用System.Data.Oraclient,最好32bit/64bit兩種10.2+版本的Oracle Client都要裝,並確定PATH變數中二者的bin目錄都有在其中,一切就搞定了。

說來簡單,卻花了我好幾個星期才解決,希望這點心得對其他也在x64叢林中挺進的同胞們有些幫助。

### Oracle Service Configuration and Troubleshooting #### Understanding Oracle Listener Startup To start the Oracle listener, which is essential for client connections to reach the database instance, one must ensure that `listener.ora` has been correctly configured with a specific name (listener_name). The command used for starting this critical component involves invoking scripts or commands designed specifically by Oracle for such purposes[^1]. For managing services associated directly with an Oracle installation on Linux systems utilizing Grid Infrastructure, operations like updating service files can be observed through messages indicating actions performed at certain timestamps; these logs provide insights into how cluster resources are managed during maintenance activities[^2]. #### Connecting Exporter Libraries to Oracle Databases When deploying exporters that interact with Oracle databases using libraries provided by Oracle itself, ensuring compatibility between versions becomes crucial especially when dealing with precompiled binaries rather than source code compilations where adjustments might still be possible before deployment[^3]. #### Handling Data Type Mismatches Between External DLLs and Oracle Procedures In scenarios involving interfacing external applications written in different languages or compiled as dynamic link libraries (.dll), issues may arise due to differences in data types supported across platforms. For example, integrating a .NET-based library returning values of type `longbool`, not natively recognized within PL/SQL procedures without conversion mechanisms being implemented externally via custom wrappers transforming output formats compatible with target environments—such as changing return types from non-standard Boolean representations found outside Java Virtual Machines towards character strings (`PChar`) more readily processed inside stored functions or triggers residing server-side[^5]. #### Proactive Monitoring Through Alerts Implementing proactive monitoring solutions allows administrators to receive timely notifications about potential security threats or general operational alerts concerning their Oracle setups. This approach helps maintain system integrity while facilitating swift responses whenever anomalies occur within networked infrastructures supporting mission-critical workloads hosted atop relational management systems[^4]. ```sql -- Example SQL script to check status of listeners and services SELECT * FROM v$session WHERE program LIKE '%(DESCRIPTION=(ADDRESS=%'; ``` --related questions-- 1. How does configuring multiple listeners affect performance? 2. What steps should be taken after replacing Clusterware entries in service configurations? 3. Can you explain best practices for maintaining up-to-date export tools connected to Oracle DBMS instances? 4. Are there alternative methods besides creating wrapper DLLs for handling incompatible data types returned by third-party APIs called from within Oracle packages? 5. Which alert categories under pro-active notification settings would most benefit organizations focused primarily on safeguarding sensitive information assets?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值