oracle empty exception oracle dataaccess - c#

I am under pressure on this one so any help would be great. This seems a long question buts its not.. I have just included as much info as possible.. rgds M
I have an Web Application with a Webservice installed on 3 environments (Dev, UAT and Prod) The system calls the web service from an SSIS package on SQL 2008 and it hits the method no Problem on the web service on all environments. I then try and open an oracle connection within the method like in the simple code below using the Oracle Assembly : Oracle.DataAccess.Client;
Hers is Sample Code :
// Create and open a connection.
OracleConnection mConnection = new OracleConnection(sCnx);
mConnection.Open(); -- Fails at this call.
The Exception Message and number are blank as per this similar issue - Oracle.DataAccess.Client.OracleException at Connection.Open()
However I have checked the Pass through setting and its set to true on all environments.
This is my connection string
<add name="cnx" connectionString="DATA SOURCE=MYHUP1.US.COM;PASSWORD=456336;PERSIST SECURITY INFO=True;USER ID=MYAPPUSER" providerName="Oracle.DataAccess.Client"/>
This is the version of the DLL that I use below. All Dlls are built and deployed with my application and in a bin folder. I have also checked that the Oracle.DataAccess.dll gets loaded from the BIN folder and not the GAC or from the Oracle 11 (64 Bit) install on the server.
Oracle.DataAccess.dll
Version 2.112.3.0
32 Bit
These are also included in the bin oci.dll, ociw32.dll, orannzsbb11.dll, oraocci11.dll, OraOps11w.dll
My application runs on a 64 bit machine but is a 32 bit app and I have this set on the App pool. Again it runs fine On DEV but not Prod. It also runs under the same service account on all 3 environments.
The thing that hammers me is the error message is blank and I have had to put loads of code in to check loaded modules and the groups that the service is running under. These all look fine.
Error Message from the Exception: Note the Message is blank.. this is the info when that I get when I pump everything out
Oracle.DataAccess.Client.OracleException at
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32
errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx*
pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) at
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode,
OracleConnection conn, IntPtr opsErrCtx, Object src) at
Oracle.DataAccess.Client.OracleConnection.Open() at
XXX.Business.XXXBO.TestConnectionAndDeleteData(Nullable`1 updateDate,
Int64 currentUserID) in C:\Development\XXX........
On my Dev and Prod Environment I have the following Version of Oracle installed but I am using my own Drivers in the Bin Directory as mentioned above so I didn't think this would matter..
DEV = Oracle Provider version 11.2.0.1.0
PROD = Oracle Provider Version 11.1.0.6.20
Would anyone have any ideas as to why this wont work on my Prod Environment. I have been over IIS with a fine comb and compared to the other environments and they are the same. Just trying to track this down to an IIS issue, or Oracle. Please note that I don't have access myself to the UAT environment which also does help!!
best regards Mick

this is what you will need to do to correct it .
Install the 32bit client along side the 64bit one.. The 64bit version does not work in regards to using standard connection string.. not sure how Oracle can let this bug go on for so long without fixing it.. installing side by side is what we did.. it will install into it's own folder so you should have no issues.. when you consume the .dll just set the copy to local = true and remove the old and re add the new .dll.. make sure you use navigate to the 4.x folder not the 2.x folder.

Related

C# Project with Oracle.DataAccess.dll (v2) on Win 7 with ORA-12154 ERROR

I have:
Win 7 (64)
VS 2010
Oracle Client 11g (32 - client_1 | 64 - client_2)
ODP.NET (32 - c:\oracle\ | 64 - c:\oracle64)
I have old project C# with added Oracle.DataAccess.dll (v2) in project references.
In Win PATH I have only C:\Oracle11g\product\11.2.0\client_2\bin; (64)
If I do start the application in any mode get ORA-Error
Oracle.DataAccess.Client.OracleException ORA-12154: TNS:could not resolve the connect identifier specified
In app.config
<connectionStrings>
<add name="ConnectionStringTEST" connectionString="DATA SOURCE=TEST;PASSWORD=TEST;PERSIST SECURITY INFO=True;USER ID=TEST"
providerName="Oracle.DataAccess.Client" />
</connectionStrings>
How do I know what TNSNAMES library uses Oracle.DataAccess.dll in C# app?
I have in REGEDIT set all ORACLE_HOME (etc.) correctly.
I thought that using tns_names which is in the directory that is listed in the PATH system, but I found that it uses tns_names of ODP.net I install certain into c:\oracle\ (32), WHY ? ()
I do not know why it not use standard Oracle client which refers in system PATH.
On the other computers where it is installed, only one oracle client (32), compiled application runs without problems(errors).
I recommend you skip TNS names altogether. If you can tnsping the server successfully (on any machine) and get the elements you need, you can use Oracle's EzConnect string instead. This has several advantages:
When you have multiple versions installed, as you mentioned, there is no confusion -- it doesn't matter because you're not using tnsnames
When you deploy on another's machine, there is no dependency on their tnsnames being set up correctly
If a server is migrated, you can update the code and not worry if any target machines for the app have had tnsnames updated or not
Advantage #3 is a double-edged sword, because with tnsnames you could edit the tns files and never have to deal with changing the connection string, but that's a very small price to pay in my opinion.
So, where you normally would say Data Source=TEST, if you tnsping test:
> tnsping test
and you get something like this:
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = myserver.foo.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = TEST)))
You could change your data source string to:
Data Source=myserver.foo.com:1521/TEST
Oracle may look for file tnsnames.ora (or more precisely the file sqlnet.ora which then defines whether tnsnames.ora shall be read or not) in these location:
Environment Variable TNS_ADMIN
Registry setting: HKLM\SOFTWARE\ORACLE\KEY_{ORACLE_HOME_NAME}\TNS_ADMIN for 64-bit
or HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_{ORACLE_HOME_NAME}\TNS_ADMIN for 32-bit
Folder %ORACLE_HOME%\network\admin
The current folder
Folder where your application binaries are located
See also this anser: Determining locatation of relevant tnsnames.ora file

Getting error '80070002' from COM .dll

I am moving a Classic ASP site from a Windows 2000 server to a Windows 2008 (both dev and prod). I have a .dll that was created in .NET 1.1. The error is occurring when function created in JScript located in this securityUtility.asp creates an ActiveXobject using the dll. The line looks as follows:
function getProfileFromLdap(user, pw){
var aClass, aProfile
aClass = new ActiveXObject("com.co.comp.security.ldap.LDAPLogin");
...
}
The error that is occurring is:
error '80070002'
E:\SITES\WWW-COMPANYSITE-COM\SITE\BINS../../siteInc/securityUtility.asp, line 850
I had run the following command to register the dll in the registry:
"C:\Windows\Microsoft.NET\Framework\v1.1.4322\RegAsm" coSecurity.dll /tlb:coSecurity.tlb
I don't know if it's worth mentioning but at one point the site worked perfectly in dev and erring when I attempted to move the site to production. I had moved the site to the new dev server (Windows 2008) so long ago. I had made notes so when I moved it up to production I knew what steps I had taken. I thought perhaps I forgot to record a step so in attempt to retrace what I did, I uninstalled the .dll and went through the steps I had recorded. It is now broken in dev but at one point it was working.
Another thing I'm not sure is worth mentioning is this site was the first site on the new dev server. .NET 1.1 was installed prior to any other framework. 4.0 and 2.0 were installed after the fact. On the prod server 4.0 was installed first and then 1.1. Not sure if that's signficant or not.
When the dev site was working I had confirmed the items were in the
registry comparing them to the old production and the new dev
servers and the new production
On the old production server there was nothing in the GAC
The coSecurity.dll is in the same file as the securityUtility.asp
(the page that the code belongs to).
The Application pool for the has "enable 32-bit applications" as true
for both of the new environments
"Everyone" is granted full rights on the .dll
I'm not sure what I'm missing!
This is what I ended up doing for those that have been beating their heads against the wall like I was:
opened a command prompt as administrator
navigated to where the dll was stored
unregistered the dll using
"C:\Windows\Microsoft.NET\Framework\v1.1.4322\RegAsm" /u
coSecurity.dll
re-registered the dll by using
"C:\Windows\Microsoft.NET\Framework\v1.1.4322\RegAsm" coSecurity.dll
/codebase
you'll get a regasm warning but should also get the message "Types
registered successfully"
After that I no longer recieved the error!
In general HRESULT 80070002 means "File Not Found".
My guess is you are missing a dependency. Try using Dependency Walker to see if there are any dependencies which should be included.
Also see this thread for some tips about registering COM servers manually.

OracleConnection is throwing empty exception

I'm trying to connect to my Oracle Database from my new PC. I've just installed Visual Studio and the ODAC. But when I try to do a simple connect Im getting an exception with an empty message, empty source, empty number, just with the error code which is -2147467259.
OracleConnection Prueba;
Prueba = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX.XXX.XXX.XXX)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XXXX)));User Id=XXX;Password=XXX;Pooling=true;Max Pool Size=10;Min Pool Size=1");
Prueba.Open();
Exception Details
This is the Exception.ToString() code:
"Oracle.DataAccess.Client.OracleException at
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32
errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx*
pOpoSqlValCtx, Object src, String procedure)
at
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode,
OracleConnection conn, IntPtr opsErrCtx, Object src)
at
Oracle.DataAccess.Client.OracleConnection.Open()
at
OracleConnectionS.Program.Main(String[] args) in
C:\Users\Simetri\Documents\Visual Studio
2010\Projects\OracleConnection\OracleConnection\Program.cs:line
19"
Any idea about why could this be happening?
UPDATE
If I run visual studio as Administrator I dont get the exception and I can connect to the database just fine.
I tried giving FULL CONTROL permission to the Oracle Directory C:\Oracle. But if I run Visual Studio in a normal way (not as administrator) I keep getting the exception.
Background Info
- I'm using Windows 7 64 bit
- Visual Studio 2010
- I can connect just find with SQL*PLUS
So after installing all sort of versions of ODAC and searching to every single post related to this.
At the end Clean Install of the 32bit version was the solution.
First you need to unistall all your other oracle client you have ever installed.
After that, look for any ODAC version you want (latest if posible) but be sure to download the 32 bit version.
WHY?
Well is something related to the version in which Visual Studio is developed in. If you are developing a console application you will have not problem with the client version, but if you are using a web project then you definitely need the 32 bit version.
Finally be sure that all of your projects in visual studio the target platform is "32 bit"
and reference the new Oracle.DataAccess.dll that you have just installed
Please try re-formatting your connection string into this form and see how it works
<add name="LoisDataAccess" connectionString="Data Source=LOISPRD;Persist Security Info=True;User ID=ABC;Password=DEF" providerName="System.Data.OracleClient" />
If the client you are using is an "Instant Client" then you might be better off by copying some Oracle-DLLs into your solution - for a walktrhough see this.
IF possible I would recommend to use a different .NET provider... in my experience most commercial ones are much less problematic than the Oracle .NET provider - see here on SO.

Oracle.DataAccess Error

I have an asp.net / C# web application running in a Windows environment.
The project builds fine and runs perfectly on my local machine's VB.net development server.
However, when I publish to the real application server I receive the following error message:
[OracleException (0x80004005): The provider is not compatible with the version of Oracle client]
[TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.]
There is a version of this application currently up and running just fine, I am testing on the live server in a different directory. I even tried snagging the Oracle.DataAccess .dll from the working application but still get the same error message.
First off: The Oracle client/provider is a mess. And that goes for both the MS one (depreciated anyway) as well as the Oracle one.
In order to connect to an Oracle DB via the ODP.NET provider three things need to be setup properly:
Oracle client needs to be setup properly ( has nothing to do with the .NET provider, this referring to the installed oracle client usually in c:\oracle)
The ODP.NET provider needs to be compatible with the installed Oracle client
The architecture of client and provider and your application need to match, you cannot use the 64bit client with an x86 provider/application and vise versa
Usually the best is to have the newest version of both. But if you want to get rid of this issue once and for all use a third party oracle .NET provider.
UPDATE
One of the better ones is from DataDirect (no affiliation):
http://www.datadirect.com/products/net/net-for-oracle/index.html
It's not just installation (no oracle client necessary), but it's also faster, fully managed, x64 and general support is a way better than what you get with the ODP.NET one. It will cost you though.
The DevArt one is pretty decent as well (and much much cheaper):
http://www.devart.com/dotconnect/oracle/
We decided for the DataDirect for extensibility reasons, this should not be relevant to you however.
Here you can find a good compilation of third parties that build .NET providers, not limited to oracle though:
http://msdn.microsoft.com/en-us/data/dd363565
I came across the same scenario before
Reading this may help you some how ODAC Oracle for .NET
about your problem in your server you have to install the whole ODAC Client from oracle
the latest version now is 4.xx
i have installed it and everything works like charm
hope this helps :)
Take Care
I was able to solve this by searching for Oracle.DataAccess.dll on the prod server.
So instead of trying to build/deploy the project with the Oracle.DataAccess.dll from my development environment, I copied the .dll down from the prod server oracle client directory and included that as a reference instead. I also set the .dll properties "Copy Local = true" and "Specific Version" = true. So it looks like there is a mismatch between the oracle client version on my dev server and the prod server.
Equals, with Oracle.DataAccess.dll Works!!!!
//using Oracle.DataAccess.Client
object pdf = null;
var queryString =#"SELECT PDF FROM DIGITAL WHERE ID_DIGITAL=1001" ; //example
var ctx = new Entities();
var entityConn = ctx.Connection as EntityConnection;
if (entityConn != null)
{
var dbConn = entityConn.StoreConnection as OracleConnection;
dbConn.Open();
var cmd = new OracleCommand(queryString, dbConn);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
pdf = reader[0];
}
}
dbConn.Close();
}
return pdf;
In addition to the other suggestions, just try running Visual Studio as administrator.
I spent a lot of time messing around with the GAC and various versions of the Oracle.DataAccess.dll, and in the end just running VS as administrator got it to run.

What is the minimum client footprint required to connect C# to an Oracle database?

I have successfully connected to an Oracle database (10g) from C# (Visual Studio 2008) by downloading and installing the client administration tools and Visual Studio 2008 on my laptop.
The installation footprint for Oracle Client tools was over 200Mb, and quite long winded.
Does anyone know what the minimum workable footprint is? I am hoping that it's a single DLL and a register command, but I have the feeling I need to install an oracle home, and set various environment variables.
I am using Oracle.DataAccess in my code.
You need an Oracle Client to connect to an Oracle database. The easiest way is to install the Oracle Data Access Components.
To minimize the footprint, I suggest the following :
Use the Microsoft provider for Oracle (System.Data.OracleClient), which ships with the framework.
Download the Oracle Instant Client Package - Basic Lite : this is a zip file with (almost) the bare minimum. I recommend version 10.2.0.4, which is much smaller than version 11.1.0.6.0.
Unzip the following files in a specific folder :
v10 :
oci.dll
orannzsbb10.dll
oraociicus10.dll
v11 :
oci.dll
orannzsbb11.dll
oraociei11.dll
On a x86 platform, add the CRT DLL for Visual Studio 2003 (msvcr71.dll) to this folder, as Oracle guys forgot to read this...
Add this folder to the PATH environment variable.
Use the Easy Connect Naming method in your application to get rid of the infamous TNSNAMES.ORA configuration file. It looks like this : sales-server:1521/sales.us.acme.com.
This amounts to about 19Mb (v10).
If you do not care about sharing this folder between several applications, an alternative would be to ship the above mentioned DLLs along with your application binaries, and skip the PATH setting step.
If you absolutely need to use the Oracle provider (Oracle.DataAccess), you will need :
ODP .NET 11.1.0.6.20 (the first version which allegedly works with Instant Client).
Instant Client 11.1.0.6.0, obviously.
Note that I haven't tested this latest configuration...
I use the method suggested by Pandicus above, on Windows XP, using ODAC 11.2.0.2.1. The steps are as follows:
Download the "ODAC 11.2 Release 3 (11.2.0.2.1) with Xcopy Deployment" package from oracle.com (53 MB), and extract the ZIP.
Collect the following DLLs: oci.dll (1 MB), oraociei11.dll (130 MB!), OraOps11w.dll (0.4 MB), Oracle.DataAccess.dll (1 MB). The remaining stuff can be deleted, and nothing have to be installed.
Add a reference to Oracle.DataAccess.dll, add using Oracle.DataAccess.Client; to your code and now you can use types like OracleConnection, OracleCommand and OracleDataReader to access an Oracle database. See the class documentation for details. There is no need to use the tnsnames.ora configuration file, only the connection string must be set properly.
The above 4 DLLs have to be deployed along with your executable.
As of 2014, the OPD.NET, Managed Driver is the smallest footprint.
Here is a code usage comparison to the non-managed versions that previous (outdated) answers suggested:
http://docs.oracle.com/cd/E51173_01/win.122/e17732/intro005.htm#ODPNT148
You will need to download these dlls and reference Oracle.ManagedDataAccess.dll in your project:
Download the ODP.NET, Managed Driver Xcopy version only
Here is a typical foot print you will need to package with your release:
Oracle.ManagedDataAccess.dll
Oracle.ManagedDataAccessDTC.dll
all together, a whopping 6.4 MB for .Net 4.0.
This way allows you to connect with ODP.net using 5 redistributable files from oracle:
Chris's blog entry: Using the new ODP.Net to access Oracle from C# with simple deployment
Edit: In case the blog every goes down, here is a brief summary...
oci.dll
Oracle.DataAccess.dll
oraociicus11.dll
OraOps11w.dll
orannzsbb11.dll
oraocci11.dll
ociw32.dll
make sure you get ALL those DLL's from the same ODP.Net / ODAC distribution to avoid version number conflicts, and put them all in the same folder as your EXE
DevArt http://www.devart.com/, formerly CoreLab (crlab.com) supplies a pure-C# Oracle client. That's a single dll, and it works fine.
Here is an update for Oracle 11.2.0.4.0. I had success with the following procedure on Windows 7 using System.Data.OracleClient.
1. Download Instant Client Package - Basic Lite: Windows 32-Bit or 64-Bit.
2. Copy the following files to a location in your system path:
32-Bit
1,036,288 2013-10-11 oci.dll
348,160 2013-10-11 ociw32.dll
1,290,240 2013-09-21 orannzsbb11.dll
562,688 2013-10-11 oraocci11.dll
36,286,464 2013-10-11 oraociicus11.dll
64-Bit
691,712 2013-10-09 oci.dll
482,304 2013-10-09 ociw32.dll
1,603,072 2013-09-10 orannzsbb11.dll
1,235,456 2013-10-09 oraocci11.dll
45,935,104 2013-10-09 oraociicus11.dll
3. Construct a connection string that omits the need for tnsnames.ora.
(See examples in the test program below.)
4. Run this minimal C# program to test your installation:
using System;
using System.Data;
using System.Data.OracleClient;
class TestOracleInstantClient
{
static public void Main(string[] args)
{
const string host = "yourhost.yourdomain.com";
const string serviceName = "yourservice.yourdomain.com";
const string userId = "foo";
const string password = "bar";
var conn = new OracleConnection();
// Construct a connection string using Method 1 or 2.
conn.ConnectionString =
GetConnectionStringMethod1(host, serviceName, userId, password);
try
{
conn.Open();
Console.WriteLine("Connection succeeded.");
// Do something with the connection.
conn.Close();
}
catch (Exception e)
{
Console.WriteLine("Connection failed: " + e.Message);
}
}
static private string GetConnectionStringMethod1(
string host,
string serviceName,
string userId,
string password
)
{
string format =
"SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)" +
"(HOST={0})(PORT=1521))" +
"(CONNECT_DATA=(SERVER=DEDICATED)" +
"(SERVICE_NAME={1})));" +
"uid={2};" +
"pwd={3};"; // assumes port is 1521 (the default)
return String.Format(format, host, serviceName, userId, password);
}
static private string GetConnectionStringMethod2(
string host,
string serviceName,
string userId,
string password
)
{
string format =
"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)" +
"(HOST={0})(PORT=1521))" +
"(CONNECT_DATA=(SERVER=DEDICATED)" +
"(SERVICE_NAME={1})));" +
"User Id={2};" +
"Password={3};"; // assumes port is 1521 (the default)
return String.Format(format, host, serviceName, userId, password);
}
}
Final tip: If you encounter the error "System.Data.OracleClient requires Oracle client software version 8.1.7", see this question.
ODAC xcopy will get you away with about 45MB.
http://www.oracle.com/technology/software/tech/windows/odpnet/index.html
I found this post on the Oracle forum very usefull as well:
How to setup Oracle Instant Client with Visual Studio
Remark: the ADO.NET team is deprecating System.Data.OracleClient so for future projects you should use ODP.NET
Reproduction:
Setup the following environment variables:
make sure no other oracle directory is in your PATH
set your PATH to point to your instant client
set your TNS_ADMIN to point to where you tnsnames.ora file is
located
set your NLS_LANG
set your ORACLE_HOME to your instant client
For me, I set NLS_LANG to
http://download-east.oracle.com/docs/html/A95493_01/gblsupp.htm#634282
I verified this was using the correct client software by using the sqlplus add-on to the instant client.
For me, I set:
SET NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
Note: before you make any changes, back up your Oracle registry key (if exist) and backup the string for any environment variables.
Read the Oracle Instant Client FAQ here

Categories

Resources