-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Attempted to read or write protected memory 'NHibernate.ADO'
PostPosted: Wed Jul 14, 2010 6:49 am 
Newbie

Joined: Wed Jul 14, 2010 6:24 am
Posts: 2
Hi All,

I am posting here an issue that i observed with NHibernate. Sorry to post here if this is already (if so please redirect me to the same).

Details of my project:
NHibernate version used - 1.2
Underlying database - Oracle 11g.
.NET language - C#, .NET Framework - 3.5

Issue:
Code:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

The inner exception is:
An exception of type 'NHibernate.ADOException' occurred in method 'DoList' of class 'Loader'

The stack trace given is:
   at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Loader\Loader.cs:line 1803
   at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Loader\Loader.cs:line 1745
   at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Loader\Loader.cs:line 1733
   at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Impl\SessionImpl.cs:line 4963
   at NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Impl\SessionImpl.cs:line 4914
   at NHibernate.Impl.CriteriaImpl.List[T]() in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Impl\CriteriaImpl.cs:line 323

The inner exception is:
An exception of type 'System.AccessViolationException' occurred in method 'Read' of class 'OpsDac'

The stack trace given is:
   at Oracle.DataAccess.Client.OpsDac.Read(IntPtr opsConCtx, IntPtr opsErrCtx, IntPtr opsSqlCtx, IntPtr& opsDacCtx, OpoSqlValCtx* pOpoSqlValCtx, OpoMetValCtx* pOpoMetValCtx, OpoDacValCtx* pOpoDacValCtx) 
   at Oracle.DataAccess.Client.OracleDataReader.Read() 
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Loader\Loader.cs:line 440 
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Loader\Loader.cs:line 181 
   at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) in C:\Documents and Settings\test\Desktop\NHibernate-1.2.1.GA-src\src\NHibernate\Loader\Loader.cs:line 1793


Code Accessing NHibernate:
I save an object say 'OBJ1' in database using ADO.NET, and then i try to load it from NHibernate, but at this time i get the above reported exception.

Below is the sample code.
Code:
public void Main()
{
    //Placeholder for saving ID of new record that is saved through ADO.
    decimal static ADOSavedObjectID;

    ADONewTestRecord obj = new ADONewTestRecord();

    //ADO.NET code to save this returns saved object db ID.
    ADOSavedObjectID = SaveThroughADO(obj);

    //Fetch the Saved record through NHibernate.
    TestNewRecordFromNHibernate = GetTestRecordThroughNHibernate(ADOSavedObjectID)

    public decimal SaveThroughADO(ADONewTestRecord obj)
    {
    //ADO code.
    }

    public TestNewRecordFromNHibernate GetTestRecordThroughNHibernate(decimal ADOSavedObjectID)
    {
        return LoadNHibernateObject(ADOSavedObjectID);
    }

    public TestNewRecordFromNHibernate LoadNHibernateObject(decimal ADOSavedObjectID)
    {
        //NHibernate session is already opened, i am not providing details.
        Session.Clear();
        IList<TestNewRecordFromNHibernate> results;
        ICriteria criteria = Session.CreateCriteria(typeof (TestNewRecordFromNHibernate));
                criteria.Add(Expression.Eq("ID", ADOSavedObjectID));
        //In this line i get the reported exception see above.
        results = criteria.List<TestNewRecordFromNHibernate>();
        return results[0];
    }
}


Top
 Profile  
 
 Post subject: Re: Attempted to read or write protected memory 'NHibernate.ADO'
PostPosted: Fri Jul 16, 2010 9:21 am 
Newbie

Joined: Wed Jul 14, 2010 6:24 am
Posts: 2
Follow the below url in NHUsers google groups on more updates on the above problem.
http://groups.google.com/group/nhusers/browse_thread/thread/425d834b19930109#


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.