安装 Oracle 11 和 12 时无法加载文件或程序集 'Oracle.DataAccess,版本 = 4.121.2.0

Could not load file or assembly 'Oracle.DataAccess, Version=4.121.2.0 when Oracle 11 and 12 are installed

在我的本地计算机上, 我用于 ASP.NET Web 开发,我有几个 Oracle 11 客户端(11.2.0.1、11.2.0.2、11.2.0.3)。我的网站使用 Oracle.DataAccess.Dll(ODP.NET 所有 32 位)

我刚刚安装了 Oracle 12c ODPwithODAC 包 32 位。

而现在的网站使用的是Oracle.DataAccess.dll11.2。不再工作了。我有这个错误:

Could not load file or assembly 'Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.] Oracle.Web.Security.OracleMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +0 Oracle.Web.Security.OracleMembershipProvider.ValidateUser(String username, String password) +105 System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +59 System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +113 System.Web.UI.WebControls.Login.AttemptLogin() +119 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +75 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +114 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +164

首先,通过 Oracle Home Selector,我选择了我想要的 Oracle Home。

在 Visual Studio 中,我在 "Oracle.DatabaseAccess" 参考中将 属性 "Specific Version" 设置为 "false"。

我遇到了这个问题。我正在使用 Oracle 12c,我不得不将 'Platform target' 更改为 x64。因此,请检查您的系统版本并将其更改为 x86 或 x64。

我之前遇到过同样的问题。我已经将启动项目(在我的案例控制台应用程序中)设置为更喜欢在构建选项卡中选中的 32 位复选框(您可以通过右键单击 project 和 select properties 找到此选项卡) .

从您的项目中删除 Oracle.DatabaseAccess 引用,然后从管理 nuget 包中重新安装它。