我开发了一个使用实体框架访问 Oracle 数据库的新应用程序。使用最新版本的 ODP.NET,这在本地按预期工作。我现在正尝试将此应用程序部署在运行许多其他遗留应用程序的生产服务器上。理想情况下,我希望我的新应用程序能够使用它自己的 ODP.NET / Oracle dll,而不必更改产品服务器上现有的 Oracle 安装。
我遵循了本指南:
http://jeremybranham.wordpress.com/2011/04/25/oracle-instant-client-with-odp-net/
根据评论,这似乎取得了一些成功。
但是,尝试创建实体对象时出现以下异常:
外部异常
Exception has been thrown by the target of an invocation.
内部异常
The type initializer for 'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.
at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized)
at System.Reflection.RtFieldInfo.InternalGetValue(Object obj, Boolean doVisibilityCheck, Boolean doCheckConsistency)
at System.Reflection.RtFieldInfo.GetValue(Object obj)
at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
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.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at MyAppMVC.Models.DataModels.STSProcedureEntities..ctor()
at MyAppMVC.Services.MyService.GetPersons(String lastName)