NHibernate - SafeHandle不能为空

时间:2015-03-10 08:45:24

标签: c# nhibernate oracle11g fluent-nhibernate

我正在使用NHibernate连接到Oracle数据库。一切都很好,直到我突然开始出现奇怪的Value cannot be null. Parameter name: SafeHandle cannot be null.错误。我不知道我改变了什么来得到这个错误,我不知道究竟是什么意思。谷歌也没有给出结果。下面是完整的堆栈跟踪。有什么想法吗?

调用BuildSessionFactory时发生错误:

 var x = Fluently.Configure()
        .Database(OracleClientConfiguration.Oracle10
            .ConnectionString(connectionString))
        .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
        .BuildConfiguration();

    return x.BuildSessionFactory();
  

在System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle)   pHandle,布尔&成功)   System.Data.Common.UnsafeNativeMethods.OCIAttrSet(OciHandle trgthndlp,   HTYPE trghndltyp,Byte [] attributep,UInt32大小,ATTR attrtype,   OciHandle errhp)在   System.Data.OracleClient.TracedNativeMethods.OCIAttrSet(OciHandle   trgthndlp,Byte [] attributep,UInt32大小,ATTR attrtype,OciHandle   errhp)在System.Data.OracleClient.OciHandle.SetAttribute(ATTR   属性,字符串值,OciErrorHandle errorHandle)at   System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(字符串   userName,String password,String serverName,Boolean   integratedSecurity,Boolean unicode,Boolean omitOracleConnectionName)   在   System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString   connectionOptions)   System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions   options,Object poolGroupProviderInfo,DbConnectionPool池,   DbConnection owningObject)at   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(的DbConnection   owningConnection,DbConnectionPool池,DbConnectionOptions选项)   在System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection   拥有对象)   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(的DbConnection   拥有对象)   System.Data.ProviderBase.DbConnectionPool.GetConnection(的DbConnection   拥有对象)   System.Data.ProviderBase.DbConnectionFactory.GetConnection(的DbConnection   拥有连接)   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(的DbConnection   outerConnection,DbConnectionFactory connectionFactory)at   System.Data.OracleClient.OracleConnection.Open()at   NHibernate.Connection.DriverConnectionProvider.GetConnection()at   NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare()   在   NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(方言   方言,IConnectionHelper connectionHelper)at   NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory   sessionFactory)at   NHibernate.Impl.SessionFactoryImpl..ctor(配置cfg,IMapping   映射,设置设置,EventListeners侦听器)   NHibernate.Cfg.Configuration.BuildSessionFactory()在   Models.SessionFactory.CreateOracleConnection(String connectionString)   在c:\ Users \ CMENGU \ Projects \ TNT \ Models \ SessionManager.cs:第21行at   TNT.SessionManager.InitOracleFactory()中   c:\ Users \ CMENGU \ Projects \ TNT \ TNT \ SessionManager.cs:第29行at   TN :.Program.Main()在c:\ Users \ CMENGU \ Projects \ TNT \ TNT \ Program.cs:line   30在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,   System.AppDomain.ExecuteAssembly上的String [] args)(String   assemblyFile,Evidence assemblySecurity,String [] args)at   Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
  在System.Threading.ExecutionContext.RunInternal(ExecutionContext   executionContext,ContextCallback回调,对象状态,布尔值   preserveSyncCtx)at   System.Threading.ExecutionContext.Run(执行上下文   executionContext,ContextCallback回调,对象状态,布尔值   preserveSyncCtx)at   System.Threading.ExecutionContext.Run(执行上下文   executionContext,ContextCallback回调,对象状态)at   System.Threading.ThreadHelper.ThreadStart()

1 个答案:

答案 0 :(得分:0)

事实证明,这是视觉工作室2015预览,它以某种方式弄乱了与oracle库相关的东西,导致了这个错误。我不得不重新格式化我的电脑几次,直到我明白了什么为止。