Oracle.DataAccess Error

2020-02-29 04:23发布

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.

5条回答
Animai°情兽
2楼-- · 2020-02-29 04:37

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.

查看更多
Explosion°爆炸
3楼-- · 2020-02-29 04:41

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.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2020-02-29 04:46
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;
查看更多
5楼-- · 2020-02-29 04:49

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

查看更多
\"骚年 ilove
6楼-- · 2020-02-29 04:51

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

查看更多
登录 后发表回答