Nhibernate配置:
var cfg = newConfiguration();
cfg.SessionFactory()
.Proxy
.DisableValidation()
.Through()
.Named("Fluent.SessionFactory")
.GenerateStatistics()
.Using(EntityMode.Poco)
.ParsingHqlThrough()
.Integrate
.Using()
.AutoQuoteKeywords()
.LogSqlInConsole()
.EnableLogFormattedSql()
.Connected
.Through()
.By()
.ByAppConfing("ConnectionString")
.CreateCommands
.Preparing()
.WithTimeout(10)
.AutoCommentingSql()
.WithMaximumDepthOfOuterJoinFetching(11)
.WithHqlToSqlSubstitutions("true 1, false 0, yes 'Y', no 'N'");
_sessionFactory= cfg.BuildSessionFactory();
调用的时候,报出错误:
System.TypeInitializationException: “Fluent.Infrastructure.Domain.NhibernateRepository.OracleSessionFactoryHelper”的类型初始值设定项引发异常。 ---> NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.OracleDataClientDriver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---> System.Reflection.TargetInvocationException: 调用的目标发生了异常。 --->System.ArgumentException: 找不到请求的 .Net Framework Data Provider。可能没有安装。
在 System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
后台根据网上的资料。补充了app.config的配置信息:
app.config:(添加如下配置)
开始报另一个错误:
:在配置了DbProviderFactories的情况下:
System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.IO.FileLoadException: 未能加载文件或程序集“oracle.dataaccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342”或它的某一个依赖项。给定程序集名称或基本代码无效。 (异常来自 HRESULT:0x80131047)
但是GAC中的程序集显示正常:
网上找了很多资料,过都没有找到可以解决的办法,还是报这个异常。
其中一些资料的地址:
麻烦使用过oracle相关的配置的兄弟姐妹帮帮忙。谢谢,比较紧急。
本机环境:
win7 64位
没有安装Oracle环境 ,GAC安装了64位相关的odp.net程序集。
测试项目执行时报上述错误。没有直接引用程序集,而是直接拷贝到bin目录下的。
注:我这个是在MSTesting项目的单元测试下执行抛出的异常。
后台我建 了个MVC项目中,一切正常,非常感谢大家的回复和启发。不过还是希望帮我看看如何能在MSTesting中正确的配置运行ODP.net