c# - 具有不变名称 'Oracle.DataAccess.Client' 的 ADO.NET 提供程序未注册

标签 c# .net oracle ado.net

我有这个在 VS2015 中开发的基于 Entity Framework 的 Web 服务代码,它一直运行良好 - 直到我的系统被新系统取代。在一个全新的系统上,我无法在同一版本的 Visual Studio 中编译代码,即使我安装了所有依赖项——包括 Oracle 11.2 Client Runtime(它说,“安装用于开发应用程序、网络服务和基本客户端软件”)。

当我在 VS2015 中构建解决方案时,抛出的错误是:Error 175: The ADO.NET provider with invariant name 'Oracle.DataAccess.Client' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.

双击错误会将我带到指向的 EDMX 文件和 EDMX 文件标记 StorageModels > Schema:

<Schema Namespace="Model.Store" Alias="Self" Provider="Oracle.DataAccess.Client" ProviderManifestToken="11.2" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">

有趣的是,DLL 文件已创建(尽管存在上述错误)但是当我用这个新文件替换服务器上现有的 DLL 时,从数据库中提取数据似乎有问题,例如:

System.ArgumentException: The specified store provider cannot be found in the configuration, or is not valid. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.
   at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
   at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
   --- End of inner exception stack trace ---
   at System.Data.EntityClient.EntityConnection.GetFactory(String providerString)
   at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
   at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
   at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
   at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config)
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
   at MyCo.MyDept.MyIntegration.MyService.DataAccess.DAL.GetLocation() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\DataAccess\DAL.cs:line 17
   at MyCo.MyDept.MyIntegration.MyService.Utility.Helpers.GetLocations() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\Utility\Helpers.cs:line 303
   at MyCo.MyDept.MyIntegration.MyService.KService.GetLocations() in C:\Users\xxxx\MyCo.MyDept.MyIntegration.MyService\KService.svc.cs:line 71

我已经尝试过其他类似线程中提供的解决方案,但似乎都没有用。任何帮助表示赞赏。谢谢。

最佳答案

迟到的答案,但如果您将 Visual Studio 与 Oracle 连接,这仍然会经常出现。如果您反复安装和卸载 ODT 并且仍然收到此错误,这对我有用:

  1. 在 Visual Studio 中,转到“工具”->“选项”
  2. 您应该找到 Oracle Developer Tools,否则您没有正确安装 ODT
  3. 打开 Oracle 开发人员工具,单击常规
  4. 这将神奇地唤醒 ODT 以完成其安装

运行 Visual Studio 2019。

关于c# - 具有不变名称 'Oracle.DataAccess.Client' 的 ADO.NET 提供程序未注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44533943/

相关文章:

c# - 从具体化 'System.Int32' 类型到 'System.Int64' 类型的指定转换无效

java - 丢失更新与不可重复读取有何不同?

c# - 查找嵌套集合的最大深度/级别

c# - Entity Framework 6 Code First 插入时的默认日期时间值

c# - 在 IQueryable 查询中减去 DateTimes

c# - 如何在 JetBrains Rider 中添加/使用 C# 库?

oracle - gradle jettyrun oracle 找不到合适的驱动程序

php - 哪个 PHP ORM 与 Oracle 一起工作并且不需要 PDO_OCI?

c# - 如何重新创建 "Index was outside the bounds of the array"添加项目到字典?

c# - 检测它是否是应用程序的最后一个实例 c#