Could not create the driver from Nhibernate.Driver.Oracledataclientdriver, Nhibernate, Version=4.0.0.4000, Culture=neutral,

Asked

Viewed 751 times

-1

I am working on an application with NHibernate and Fluent Nhibernate. I’m having trouble with my settings App.config. I don’t know exactly what’s wrong with my settings.

I’m getting this Exception:

Nhibernate.Hibernateexception: Could not create the driver from Nhibernate.Driver.Oracledataclientdriver, Nhibernate, Version=4.0.0.4000, Culture=neutral, Publickeytoken=aa95f207798dfdb4.

My App.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <publisherPolicy apply="no" />
        <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
        <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <connectionStrings>
    <add name="AppDS" providerName="Oracle.ManagedDataAccess.Client" connectionString="[Minha connectionString]" />
    <add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="[Minha connectionString]" />
  </connectionStrings>
  <appSettings>
    <add key="SchemaAppDS" value="ENERGISA_DESENV" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
      <property name="dialect">NHibernate.Dialect.Oracle09gDialect</property>
      <property name="connection.connection_string_name">AppDS</property>
      <property name="show_sql">true</property>
    </session-factory>
  </hibernate-configuration>
</configuration>

My Stacktrace is like this:

Test Name:	TestMethod1
Test FullName:	NHibernate_Test.UnitTest1.TestMethod1
Test Source:	c:\Users\misantos\Documents\Visual Studio 2013\Projects\NHibernate\NHibernate-Test\UnitTest1.cs : line 19
Test Outcome:	Failed
Test Duration:	0:00:00

Result Message:	
Unable to create instance of class NHibernate_Test.UnitTest1. Error: Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Common.Service.SubstationService", name = "(none)".
Exception occurred while: Calling constructor Common.Repository.SubstationRepository().
Exception is: FluentConfigurationException - An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.


-----------------------------------------------
At the time of the exception, the container was:

  Resolving Common.Service.SubstationService,(none)
  Resolving parameter "repository" of constructor Common.Service.SubstationService(Common.Repository.Interface.ISubstationRepository repository)
    Resolving Common.Repository.SubstationRepository,(none) (mapped from Common.Repository.Interface.ISubstationRepository, (none))
    Calling constructor Common.Repository.SubstationRepository()
 ---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

 ---> NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.OracleDataClientDriver, NHibernate, Version=4.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---> System.Reflection.TargetInvocationException: Uma exceção foi acionada pelo destino de uma chamada. ---> System.ArgumentException: Não foi possível localizar o Provedor de Dados .Net Framework solicitado. Talvez ele não esteja instalado..
Result StackTrace:	
em System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
   em NHibernate.Driver.ReflectionBasedDriver..ctor(String providerInvariantName, String driverAssemblyName, String connectionTypeName, String commandTypeName)
   em NHibernate.Driver.OracleDataClientDriver..ctor()
 --- End of inner exception stack trace ---
    em System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   em System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   em System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   em System.Activator.CreateInstance(Type type, Boolean nonPublic)
   em System.Activator.CreateInstance(Type type)
   em NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
   em NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
 --- End of inner exception stack trace ---
    em NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
   em NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings)
   em NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings)
   em NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
   em NHibernate.Cfg.Configuration.BuildSettings()
   em NHibernate.Cfg.Configuration.BuildSessionFactory()
   em FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
 --- End of inner exception stack trace ---
    em FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
   em Common.Models.DataContext.SessionFactoryHelper.CreateSessionFactory() na c:\Users\misantos\Documents\Visual Studio 2013\Projects\NHibernate\Common\Models\DataContext\SessionFactoryHelper.cs:linha 35
   em Common.Repository.SubstationRepository..ctor() na c:\Users\misantos\Documents\Visual Studio 2013\Projects\NHibernate\Common\Repository\SubstationRepository.cs:linha 20
   em lambda_method(Closure , IBuilderContext )
   em Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context)
   em Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
   em Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
   em Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
   em Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
   em Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
   em lambda_method(Closure , IBuilderContext )
   em Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context)
   em Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
   em Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
   em Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
   em Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
 --- End of inner exception stack trace ---
    em Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
   em Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
   em Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
   em Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
   em NHibernate_Test.TestBase.Resolve[T]() na c:\Users\misantos\Documents\Visual Studio 2013\Projects\NHibernate\NHibernate-Test\TestBase.cs:linha 21
   em NHibernate_Test.UnitTest1..ctor() na c:\Users\misantos\Documents\Visual Studio 2013\Projects\NHibernate\NHibernate-Test\UnitTest1.cs:linha 15

What am I doing wrong?

  • Do you have the / client driver installed on the machine where you are serving the application? And if I don’t miss the memory, you also need to add the oracle dll reference to your project. (Oracle.DataAcess.dll)

  • Yes I have the client driver installed on the machine. I did not have Oracle.DataAcess.dll, I installed it in version 4.112.3.0. But is giving a new Exception. Oracle.DataAccess.Client.Oracleexception: The Provider is not compatible with the version of Oracle client.

  • According to this post on the stack in English, may be the version of Oracle Data Provider that does not support 64 bits, the comrade decided to change the target of Any CPU to x86. https://stackoverflow.com/questions/11728521/could-not-create-the-driver-from-nhibernate-driver-oracledataclientdriver-with

  • Thanks, but it didn’t solve for me. I left only my project Testing in Any CPU, otherwise unit tests do not appear.

1 answer

0

Go to References and select the oracle.dataaccess. Then go to properties and change the Copy Local property to True. It worked for me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.