4

I'm trying to use System.Data.OracleClient instead of Oracle.DataAccess with Fluent Nhibernate . From what I understand, in order to achieve this I should change my driver from OracleDataClientDriver to OracleClientDriver. I've configured it like below, but I get an error that looks like it is still trying to use OracleDataClientDriver. What am I doing wrong?

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

Here is the error, it is still looking for Oracle.DataAccess which I'm trying to get away from.

[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
5
  • 5
    I believe you should also change OracleDataClientConfiguration to OracleClientConfiguration Commented Jul 8, 2013 at 23:29
  • 1
    Please note that Microsoft deprecated the System.Data.OracleClient and recommends that you use a third-party Oracle provider instead. Commented Jul 9, 2013 at 5:40
  • Ideally I would move away from System.Data.OracleClient but as you know sometimes in the real world you're limited by your environment :( Rivarolle, post your answer so I can give you credit. Cannot believe I overlooked that. I just gave my face a high five. Commented Jul 9, 2013 at 13:57
  • @PapaBurgundy did you solve your problem, it where great if you have a solution Commented Jul 22, 2013 at 8:45
  • 3
    @Higune I did. Take a look at the comments above. There were 2 places I had to change it. The end result should use OracleClientConfiguration and OracleClientDriver instead of OracleDataClientConfiguration and OracleDataClientDriver Commented Jul 22, 2013 at 14:48

1 Answer 1

5

Use OracleClientConfiguration and OracleClientDriver instead of OracleDataClientConfiguration and OracleDataClientDriver

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

The comments in the question solved my problem. I've posted this answer for the benefit of others, @PapaBurgundy & @Rivarolle deserve full credit for the answer.

Sign up to request clarification or add additional context in comments.

1 Comment

This answer gave me the place to fix it. In my case, I needed "NHibernate.Driver.OracleManagedDataClientDriver". Full context of my fix : _sessionFactory = Fluently.Configure() .Database(OracleDataClientConfiguration .Oracle10 .ConnectionString(c => c.Is(myConnectionString)) .Provider<NHibernate.Connection.DriverConnectionProvider>() .Driver<NHibernate.Driver.OracleManagedDataClientDriver>() )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.