NHibernate - SafeHandle Cannot be Null

本文关键字:be Null Cannot SafeHandle NHibernate | 更新日期: 2024-11-07 02:15:12

我正在使用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();

at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean&success) at System.Data.Common.UnsafeNativeMethods.OCIAttrSet(OciHandle trgthndlp, HTYPE trghndltyp, Byte[] attributep, UInt32 size, ATTR attrtype, OciHandle errhp) at System.Data.OracleClient.TracedNativeMethods.OCIAttrSet(OciHandle trgthndlp, Byte[] attributep, UInt32 size, ATTR attrtype, OciHandle errhp) at System.Data.OracleClient.OciHandle.SetAttribute(ATTR 属性, 字符串值, OciErrorHandle errorHandle) at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String 用户名, 字符串密码, 字符串服务器名称, 布尔值 集成安全,布尔统一码,布尔省略OracleConnectionName) 在 System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString 连接选项) 在 System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions 选项, 对象池组提供程序信息, 数据库连接池池, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection 拥有连接, 数据库连接池池, 数据库连接选项选项) at 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(Dialect 方言,IConnectionHelper connectionHelper) at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping 映射、设置设置、事件侦听器侦听器)在 NHibernate.Cfg.Configuration.BuildSessionFactory() at Models.SessionFactory.CreateOracleConnection(String connectionString) in c:''Users''CMENGU''Projects''TNT''Models''SessionManager.cs:line 21 at 三硝基甲苯。SessionManager.InitOracleFactory() in c:''Users''CMENGU''Projects''TNT''TNT''SessionManager.cs:line 29 at 三硝基甲苯。Program.Main() in c:''Users''CMENGU''Projects''TNT''TNT''Program.cs:line 30 at System.AppDomain._nExecuteAssembly(运行时程序集, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

NHibernate - SafeHandle Cannot be Null

事实证明,正是Visual Studio 2015预览版以某种方式搞砸了与oracle库相关的内容,从而导致了此错误。我不得不重新格式化我的电脑几次,直到我明白发生了什么。