我用 NHibernate 连接sql 时什么都没问题
但一连接 Oracle 总是连接不上!!执行查询时就报错···
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 <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly. 堆栈跟踪: 
[HibernateException: 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 <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.]
   NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName) +177
   NHibernate.Driver.OracleDataClientDriver..ctor() +23[TargetInvocationException: 调用的目标发生了异常。]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +103
   System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +261
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
   NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary settings) +107[HibernateException: Could not create the driver from NHibernate.Driver.OracleDataClientDriver.]
   DataAccess.CommonDL..ctor() in D:\WORK\NHibernate\NHibernate\DataAccess\CommonDL.cs:25
   Rules.CommonTools..ctor() in D:\WORK\NHibernate\NHibernate\Rules\CommonTools.cs:13
   NHibernate.btnAll_Click(Object sender, EventArgs e) in d:\work\NHibernate\NHibernate\Web\NHibernateQuery.aspx.cs:40
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4919 
能不能将 连接oracle 时的 config 文件共享一下!!!

解决方案 »

  1.   

    你连接Oracle的链接字串有问题。建议你检查一下!
      

  2.   

    ^_^问题自己解决了!!!就改了config 文件
      <configSections>
        <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </configSections>  <nhibernate>
        <!--连接数据提供者 -->
        <add 
        key="hibernate.connection.provider" 
        value="NHibernate.Connection.DriverConnectionProvider" 
        />
        <!--连接数据方言最常用的是MsSql2000Dialect -->
        <add 
        key="hibernate.dialect" 
        value="NHibernate.Dialect.Oracle9Dialect" 
        />
        <!--连接数据驱动类 -->
        <add 
        key="hibernate.connection.driver_class" 
        value="NHibernate.Driver.OracleClientDriver" 
        />
        <!--连接数据库 -->
        <add 
        key="hibernate.connection.connection_string" 
        value="Data Source=cast511; User Id=ben; Password=ben; Persist Security Info=true" 
        />
      </nhibernate>