Fluent NHibernate - 配置Oracle数据提供程序ODP [英] Fluent NHibernate - Configure Oracle Data Provider ODP

查看:267
本文介绍了Fluent NHibernate - 配置Oracle数据提供程序ODP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NHibernate和流利的NHibernate的全新,我试图获得以下配置工作。

I am brand new to NHibernate and Fluent NHibernate and I am trying to get the following confguration to work.

private static ISessionFactory CreateSessionFactory()
{
     return Fluently.Configure() 
       .Database(
       OracleDataClientConfiguration.Oracle10.ConnectionString("Data Source=mysource;User ID=myid;Password=mypwd;")                  
          )
         .Mappings(m =>
            m.FluentMappings.AddFromAssemblyOf<Program>())
         .BuildSessionFactory();

    }



我已经引用了Oracle.DataAccess程序集。我使用VS 2010和.Net 4

I have the Oracle.DataAccess assembly referenced. I am using VS 2010 and .Net 4

我得到以下异常:

FluentNHibernate.Cfg.FluentConfigurationException未处理
消息=在创建SessionFactory时使用了无效或不完整的配置。检查PotentialReasons集合和InnerException获取更多细节。

FluentNHibernate.Cfg.FluentConfigurationException was unhandled Message=An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

Source = FluentNHibernate
StackTrace:
在FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory :\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 98
在HibernateLearning.Program.CreateSessionFactory()在C:\Projects\CPS测试概念\Main \Source\CPSTestConcepts\Source\HibernateLearning\Program.cs:line 48
在HibernateLearning.Program.Main(String [] args)在C:\Projects\CPS测试概念\主\Source\CPSTestConcepts\Source\HibernateLearning\Program.cs:第21行
在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String [] args)
在System.AppDomain.ExecuteAssembly字符串assemblyFile,Evidence assemblySecurity,String [] args)
在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)
在系统。 Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态,布尔值ignoreSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)
在System.Threading.ThreadHelper .ThreadStart()
InnerException:NHibernate.HibernateException
消息=无法从NHibernate.Driver.OracleDataClientDriver,NHibernate,Version = 2.1.2.4000,Culture = neutral,PublicKeyToken = aa95f207798dfdb4创建驱动程序。
Source = NHibernate
StackTrace:
在NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary 2设置)
在NHibernate.Connection.ConnectionProvider.Configure
2 settings)
在NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary 2设置)
在NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary 在NHibernate.Cfg.Configuration.BuildSettings()
在NHibernate.Cfg.Configuration.BuildSessionFactory()
在FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93
InnerException:System.Reflection.TargetInvocationException
消息=异常已由目标抛出调用。
Source = mscorlib
StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type,Boolean publicOnly,Boolean noCheck,Boolean& canBeCached,RuntimeMethodHandleInternal& ctor,Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly,Boolean skipCheckThis,Boolean fillCache)
在System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,Boolean skipVisibilityChecks,Boolean skipCheckThis,Boolean fillCache)
在System.Activator.CreateInstance类型,布尔nonPublic)
在System.Activator.CreateInstance(类型类型)
在NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(类型类型)
在NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary- 2设置)
InnerException:NHibernate.HibernateException
Message =无法找到程序集中的IDbCommand和IDbConnection实现Oracle.DataAccess。确保程序集Oracle.DataAccess位于应用程序目录或全局程序集缓存中。如果程序集在GAC中,请在应用程序配置文件中使用元素指定程序集的全名。
Source = NHibernate
StackTrace:
at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName,String connectionTypeName,String commandTypeName)
在NHibernate.Driver.OracleDataClientDriver..ctor )
InnerException:

Source=FluentNHibernate StackTrace: at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 98 at HibernateLearning.Program.CreateSessionFactory() in C:\Projects\CPS Test Concepts\Main\Source\CPSTestConcepts\Source\HibernateLearning\Program.cs:line 48 at HibernateLearning.Program.Main(String[] args) in C:\Projects\CPS Test Concepts\Main\Source\CPSTestConcepts\Source\HibernateLearning\Program.cs:line 21 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: NHibernate.HibernateException Message=Could not create the driver from NHibernate.Driver.OracleDataClientDriver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. Source=NHibernate StackTrace: at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary2 settings) at NHibernate.Connection.ConnectionProvider.Configure(IDictionary2 settings) at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary2 settings) at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary2 properties) at NHibernate.Cfg.Configuration.BuildSettings() at NHibernate.Cfg.Configuration.BuildSessionFactory() at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93 InnerException: System.Reflection.TargetInvocationException Message=Exception has been thrown by the target of an invocation. Source=mscorlib StackTrace: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings) InnerException: NHibernate.HibernateException Message=The IDbCommand and IDbConnection implementation in the assembly Oracle.DataAccess could not be found. Ensure that the assembly Oracle.DataAccess is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly. Source=NHibernate StackTrace: at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName) at NHibernate.Driver.OracleDataClientDriver..ctor() InnerException:

推荐答案

我想出来。当你引用ODP时,你必须将引用的copy local属性设置为true,否则它将找不到它正在寻找的对象。

I figured it out. When you reference the ODP you have to set the the copy local property of the reference to true otherwise it won't find the objects it is looking for.

一个障碍,我相信会有更多,但我喜欢这些工具!

One hurdle down, I'm sure there will be more but I am loving these tools!

Paul

这篇关于Fluent NHibernate - 配置Oracle数据提供程序ODP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆