我们正在使用Oracle.DataAccess.dll程序集版本2.102.2.20(32位)。我将我们的Web API应用程序部署到IIS,并尝试打开和关闭连接:
在我的本地机器上,一切都很好,但是在此服务器上,当尝试初始化OracleConnection时会引发异常:
The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client
我已经在服务器上安装了Oracle客户端11.2(32位),并且我可以看到在GAC(c:\ windows \ assembly)中,Oracle.DataAccess程序集以32位处理器架构安装。它在我们的一个服务器上运行良好,但是在此服务器上却无法使用。
在IIS中,我还设置了应用程序池的“启用32位应用程序”。
如何解决?我已经花费超过10个小时尝试不同的方法:(
最理想的情况是能够在不需要在服务器上安装Oracle Client的情况下使用Oracle.DataAccess.dll。
private static void CheckConnectionUsingOracleClient(string connection)
{
var logger = DiContainer.Resolve<ILogger>();
try
{
logger.LogInfo("Trying to connect to " + connection);
// check whether you can connect to the shop using Oracle.DataAccess
using (var cnn = new Oracle.DataAccess.Client.OracleConnection(connection))
{
cnn.Open();
cnn.Close();
}
logger.LogInfo("Succeeded to connect to " + connection);
}
catch (System.Exception ex)
{
logger.LogError("Failed to connect to " + connection, ex);
}
}
在我的本地机器上,一切都很好,但是在此服务器上,当尝试初始化OracleConnection时会引发异常:
The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client
我已经在服务器上安装了Oracle客户端11.2(32位),并且我可以看到在GAC(c:\ windows \ assembly)中,Oracle.DataAccess程序集以32位处理器架构安装。它在我们的一个服务器上运行良好,但是在此服务器上却无法使用。
在IIS中,我还设置了应用程序池的“启用32位应用程序”。
如何解决?我已经花费超过10个小时尝试不同的方法:(
最理想的情况是能够在不需要在服务器上安装Oracle Client的情况下使用Oracle.DataAccess.dll。