I can't get around a weird "System.AccessViolationException" on NHibernate ISession.Save.
The same piece of code works fine with M$SQL and MySQL. I tried switching over from
(ODP.NET doc says it support TransactionScope) - however, the application simply disappear without even getting an AccessViolationException. In this case, last thing I see in log is:
2009-04-09 21:08:25,234 [10] DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new IDbCommand, open IDbCommands: 1
2009-04-09 21:08:25,234 [10] DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: select SYSTEMUSER_SEQ.nextval from dual
2009-04-09 21:08:25,250 [10] DEBUG NHibernate.SQL - select SYSTEMUSER_SEQ.nextval from dual
2009-04-09 21:08:25,250 [10] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
2009-04-09 21:08:27,390 [10] DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDbCommand, open IDbCommands: 0
2009-04-09 21:08:27,390 [10] DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
(c) Set OracleConnection.Unicode to true, i.e. add the following to connection string
(d) Be careful with LONG, LONG RAW, OBJECT, XMLTYPE - try comment out first if any.
I can't find anything "funny" with my Person's table. And like I said, ODP.NET saved this successfully if I just commented out TransactionScope! So it should have nothing to do with it!
And my NHibernate mapping file (Googled a bit don't think it is problem with NHibernate, also this Save works fine with MySQL and M$SQL, only Oracle making trouble):
I downloaded "303312_intl_i386_zip.exe " from following M$ URL.
"The upgrade patch canno be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade path."
"Article ID: 923028 - Last Review: March 25, 2009 - Revision: 4.0 FIX: Error message when you run a .NET Framework 2.0 Remoting application: "Unhandled Exception: System.AccessViolationException"
Any suggestion? Help! Really need some help on this.
2009-04-09 07:31:24,609 [10] ERROR SimpleConsoleTest - xxxxx.Util.ApplicationException Exception context: xxxxx.Util.ApplicationExceptionContext, Subject: Save failed, Description: xxxxx.Util.Person, Id:-1, Name:xxxxx.Util.Name, FirstName:John, MiddleName:, LastName:Kennedy, PrimaryEmail:
[email protected], Type:undefined, GenericObj:object type: xxxxx.Util.Generic.GenericObject, object name: , object classifier: Person, TypeName: xxxxx.Util.Person, DAOTypeName: xxxxx.Util.PersonDAO, Util, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, DAOCreateInstanceArg: , CreateDate: 4/9/2009 7:31:19 AM, Properties: , Parents count:0, Children:, DatabaseInitiated: False, BasicAudit:xxxxx.Util.Security.BasicAudit, CreateDate:4/9/2009 7:31:19 AM, CreatedBy:-1, LastUpdate:1/1/1753 12:00:00 AM, LastUpdateBy:-1, StackTrace: at xxxxx.Util.ApplicationException.Throw(String strSubject, String strSummary, String strDescription, Exception oInnerException) in C:\dev\xxxxx\NET3.0\Util\ApplicationException.cs:line 176
at xxxxx.Util.PersonDAO.Save(IGenericTO& oPerson) in C:\dev\xxxxx\NET3.0\Util\PersonDAO.cs:line 349
at xxxxx.NUnitTest.TestDAOUtil.TestSaveAndSelectByKey(IGenericTO& o) in C:\dev\xxxxx\NET3.0\NUnitTest\TestDAOUtil.cs:line 349
at xxxxx.NUnitTest.TestDAOUtil.TestDAO(Boolean bTestDelete) in C:\dev\xxxxx\NET3.0\NUnitTest\TestDAOUtil.cs:line 278
at SimpleConsoleTest.Program.TestPeronDAO() in C:\dev\xxxxx\NET3.0\SimpleConsoleTest\Program.cs:line 131
at SimpleConsoleTest.Program.Main() in C:\dev\xxxxx\NET3.0\SimpleConsoleTest\Program.cs:line 45
at System.AppDomain._nExecuteAssembly(Assembly 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)
at System.Threading.ThreadHelper.ThreadStart()
{Inner Exception: NHibernate.ADOException: cannot open connection ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Data.Common.UnsafeNativeMethods.OraMTSEnlCtxGet(Byte[] lpUname, Byte[] lpPsswd, Byte[] lpDbnam, OciHandle pOCISvc, OciHandle pOCIErr, UInt32 dwFlags, IntPtr& pCtxt)
at System.Data.OracleClient.TracedNativeMethods.OraMTSEnlCtxGet(Byte[] userName, Byte[] password, Byte[] serverName, OciHandle pOCISvc, OciHandle pOCIErr, IntPtr& pCtxt)
at System.Data.OracleClient.OciEnlistContext..ctor(Byte[] userName, Byte[] password, Byte[] serverName, OciServiceContextHandle serviceContextHandle, OciErrorHandle errorHandle)
at System.Data.OracleClient.OracleInternalConnection.Enlist(String userName, String password, String serverName, Transaction transaction, Boolean manualEnlistment)
at System.Data.OracleClient.OracleInternalConnection.Activate(Transaction transaction)
at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OracleClient.OracleConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection()
at NHibernate.Impl.SessionFactoryImpl.OpenConnection()
--- End of inner exception stack trace ---
at NHibernate.Impl.SessionFactoryImpl.OpenConnection()
at NHibernate.AdoNet.ConnectionManager.GetConnection()
at NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd)
at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
at NHibernate.Id.SequenceGenerator.Generate(ISessionImplementor session, Object obj)
at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId(Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event)
at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event)
at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event)
at NHibernate.Impl.SessionImpl.Save(Object obj)
<b>at xxxxx.Util.PersonDAO.Save(IGenericTO&amp; oPerson) in C:\dev\xxxxx\NET3.0\Util\PersonDAO.cs:line 332 {Inner Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</b>
at System.Data.Common.UnsafeNativeMethods.OraMTSEnlCtxGet(Byte[] lpUname, Byte[] lpPsswd, Byte[] lpDbnam, OciHandle pOCISvc, OciHandle pOCIErr, UInt32 dwFlags, IntPtr&amp; pCtxt)
at System.Data.OracleClient.TracedNativeMethods.OraMTSEnlCtxGet(Byte[] userName, Byte[] password, Byte[] serverName, OciHandle pOCISvc, OciHandle pOCIErr, IntPtr&amp; pCtxt)
at System.Data.OracleClient.OciEnlistContext..ctor(Byte[] userName, Byte[] password, Byte[] serverName, OciServiceContextHandle serviceContextHandle, OciErrorHandle errorHandle)
at System.Data.OracleClient.OracleInternalConnection.Enlist(String userName, String password, String serverName, Transaction transaction, Boolean manualEnlistment)
at System.Data.OracleClient.OracleInternalConnection.Activate(Transaction transaction)
at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OracleClient.OracleConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection()
at NHibernate.Impl.SessionFactoryImpl.OpenConnection()