4

我正在尝试使用 System.Data.OracleClient 而不是 Oracle.DataAccess 和 Fluent Nhibernate 。据我了解,为了实现这一点,我应该将驱动程序从 OracleDataClientDriver 更改为 OracleClientDriver。我已经像下面这样配置它,但我收到一个错误,看起来它仍在尝试使用 OracleDataClientDriver。我究竟做错了什么?

FluentConfiguration configuration = Fluently.Configure()                
            .Database(
            OracleDataClientConfiguration.Oracle10
            .ConnectionString(x => x.FromConnectionStringWithKey(connString))
            .Provider<NHibernate.Connection.DriverConnectionProvider>()
            .Driver<NHibernate.Driver.OracleClientDriver>()            
               )

这是错误,它仍在寻找我试图摆脱的 Oracle.DataAccess。

[NullReferenceException: Object reference not set to an instance of an object.]
   NHibernate.Driver.OracleDataClientDriver..ctor() +134

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
   System.Activator.CreateInstance(Type type) +6
   NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) +58
   NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings) +194

[HibernateException: Could not create the driver from NHibernate.Driver.OracleDataClientDriver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.]
   NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings) +334
   NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings) +233
   NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings) +558
   NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties) +1328
   NHibernate.Cfg.Configuration.BuildSettings() +85
   NHibernate.Cfg.Configuration.BuildSessionFactory() +102
   FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +72
4

1 回答 1

5

使用OracleClientConfigurationOracleClientDriver 而不是 OracleDataClientConfiguration 和 OracleDataClientDriver

FluentConfiguration configuration = Fluently.Configure()                
            .Database(
            OracleClientConfiguration.Oracle10
            .ConnectionString(x => x.FromConnectionStringWithKey(connString))
            .Provider<NHibernate.Connection.DriverConnectionProvider>()
            .Driver<NHibernate.Driver.OracleClientDriver>()            
               )

问题中的评论解决了我的问题。为了他人的利益,我发布了这个答案,@PapaBurgundy 和 @Rivarolle 的答案值得充分肯定。

于 2014-05-08T16:32:05.507 回答