Asked by:
The type or namespace name 'OracleClient' doesn't exist in the namespace 'System.Data' (Are you missing an assembly reference?)

Question
-
User899592849 posted
Hello:
I have 2 systems - 2k8 server with oracle 32bit and 2k8 server with oracle 64bit.
I am testing the same OracleChk.aspx page on both systems.
2k8 server with oracle 32 bit gives no errors.
2k8 server with oracle 64bit gives the following errors:
error cs0234: The type or namespace name 'OracleClient' doesn't exist in the namespace 'System.Data' (Are you missing an assembly reference?)
Does it mean OracleClient only work on Oracle 32 bit? Please advice. thanks
using System; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using System.Data.OracleClient; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class CheckOra : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { OracleConnection sConn = new OracleConnection("Password=xxx;User ID=xxx;Data Source=Hello.WORLD;Persist Security Info=True;"); try { sConn.Open(); Response.Write("Successfully Opened"); } catch (Exception ex) { Response.Write("Could not establish connection:<br /><br />" + ex.Message); } } }
Tuesday, August 5, 2014 4:19 PM
All replies
-
User269602965 posted
You have to use the 64-bit Oracle.DataAccess.dll when using the 64-bit Oracle client installed on your 64-bit application server
and of course, compile the page as 64-bit.
I obtain the exact version and bitness of Oracle.DataAccess.dll to match the client (look in your Oracle client HOME > ODP.NET > BIN > 4 directory
and place it in the /BIN directory of the application, make LOCAL reference, and compile to avoid confusion.
Tuesday, August 5, 2014 7:44 PM -
User899592849 posted
I followed your steps and I got different error:
Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Does it mean I need a newer version of runtime Java on my system?
Wednesday, August 6, 2014 9:57 AM -
User269602965 posted
On the Windows 2008 64-bit machine where is the Database being called by the application?
What version and bitness is the Oracle database?
Wednesday, August 6, 2014 6:50 PM -
User899592849 posted
The database resides on another 2k8 server. Oracle 11gR2 64bit
Thursday, August 7, 2014 1:05 PM -
User269602965 posted
Yes Good database. I use that too.
Let's back up and do clean install.
Uninstall Oracle client(s) on the application server.
Go to registry HKEY Local Machine > Software and remove the Oracle Key
Find your Oracle home and make sure it is an empty directory
Reboot and install this driver and Client. When you run the installer, use the CLIENT INSTALLATION option.
http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
64-bit ODAC 11.2 Release 5 (11.2.0.3.20) for Windows x64
ODAC1120320_x64.zip - 225 MB (230,297,429 bytes)
make sure you can execute a test query from SQL PLUS prompt to ensure good connection to database
(no firewall issues blocking Oracle listening port, tnsnames.ora properly configured, etc.)
Then follow my previous steps to obtain the exact same oracledataaccess.dll used by your client install
with LOCALreference made to it in the /BIN directory of APP.
And make sure your application is explicitly compiled at x64 and not ANY or x86.
http://docs.oracle.com/cd/E11882_01/appdev.112/e10767/toc.htm
http://docs.oracle.com/cd/E11882_01/win.112/e23174/toc.htm
Thursday, August 7, 2014 8:04 PM -
User269602965 posted
And remove these from your code
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient; (for MS SQL)
you want
using Oracle.DataAccess.Client;
Thursday, August 7, 2014 8:09 PM -
User899592849 posted
Thanks I will ask the database guy intall the new Oracle client.
The above page is one of the pages I am trying to migrate from 2k3 server to 2k8 server. So far I already seen some errors like above error. Since all of the applications are written to run on 2k3 server (32bit) machine with .Net Framework 2.0, what I need to do in order to make those applications to work on 2k8 server 64bit?
What Oracle client should I install since all applications are written for .Net framework 2.0 to begin with?
I need to change all pages to - using Oracle.DataAccess.Client;
Thanks
Thursday, August 7, 2014 11:05 PM -
User269602965 posted
The above referenced installation link supports .NET 2.0/3.5 and .NET 4.0
But of course, you need to go into the ODP.NET folder of your Oracle home to get the right oracle.dataaccess.dll
home/odp.net/bin/2.x/Oracle.DataAccess.dll for .NET 2.0/3.5 apps
home/odp.net/bin/4/Oracle.DataAccess.dll for .NET 4.0 compiled apps
copy the dll you need into the /BIN folder of your app and make local reference.
Friday, August 8, 2014 6:07 PM