Attempted to read or write protected memory 'NHibernate.ADOException' occurred in method 'DoList' of class 'Loader'

774 views
Skip to first unread message

NHibernate1

unread,
Jul 16, 2010, 4:20:08 AM7/16/10
to nhusers
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];
}
}

Frans Bouma

unread,
Jul 16, 2010, 4:38:13 AM7/16/10
to nhu...@googlegroups.com
> 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.

Likely a problem with ODP.NET. I'm not sure which version of ODP.NET
you're using, but be sure you're using a recent build and also that you
install the proper version for your OS, so the 64bit version for your 64bit
OS or the 32bit version for the 32bit OS.

ODP.NET is a .NET wrapper around a Java based client, and the
exception occurs inside the client, not the code calling it.

FB

> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to
> nhusers+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.

f....@free.fr

unread,
Jul 16, 2010, 5:18:06 AM7/16/10
to nhu...@googlegroups.com, Frans Bouma, nhu...@googlegroups.com
I had exactly the same issue with x64 OS and ODP.Net. (In my case it was XP 64)
Occurence : running debug in x64 using VS 2008.
I think Frans is right.

Selon Frans Bouma <fr...@sd.nl>:

NHibernate1

unread,
Jul 16, 2010, 5:33:42 AM7/16/10
to nhusers

Thanks Frans & f...@free.fr for your quick responses and
clarifications.

I am using Microsoft Windows XP Professional 32 bit SP33 OS.

I have installed - Oracle 11g Client (11.1.0.6) and ODAC for Oracle
Client (11.1.0.6.21), ODP.NET (Version -ODAC for Oracle Client
(11.1.0.6.21)) - But, i am not sure of whether this is 32 bit ODP.NET
or 64 bit ODP.NET.
_____
If there is a way to dentify whether ODP.NET is 32bit compatible or
64bit compatible please let me know. Meanwhile i will try to figure
out the same.
_____

Also please note that I face this exception intermittently.
_____
> > NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImp­l
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -

Frans Bouma

unread,
Jul 16, 2010, 5:51:23 AM7/16/10
to nhu...@googlegroups.com
> Thanks Frans & f...@free.fr for your quick responses and clarifications.
>
> I am using Microsoft Windows XP Professional 32 bit SP33 OS.
>
> I have installed - Oracle 11g Client (11.1.0.6) and ODAC for Oracle Client
> (11.1.0.6.21), ODP.NET (Version -ODAC for Oracle Client
> (11.1.0.6.21)) - But, i am not sure of whether this is 32 bit ODP.NET or
64
> bit ODP.NET.

You don't have to install a client if you install ODP.NET. So for
testing, uninstall both ODAC and the oracle 11g client and download the
32bit ODP.NET 11g provider and only install that one. When you install two
clients (which you actually did) it might be you get two oracle homes
defined and you might use the 11g client with the odp.net assembly causing
mismatches.

We've seen the same error in Sybase ADO.NET providers for ASE, which
use the same setup as ODP.NET, caused by the same kind of setup error.

FB

------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Twitter: http://twitter.com/FransBouma
Microsoft MVP (C#).
------------------------------------------------------------------------

allan....@gmail.com

unread,
Jul 16, 2010, 9:02:43 AM7/16/10
to nhusers
This usually occurs when you're debugging something in IIS. The fix
that worked for me was the following:

In Visual Studio, go to Tools => Options => Debugging => General =>
Uncheck "Suppress JIT optimization on module load"
> > > >http://groups.google.com/group/nhusers?hl=en.-Hide quoted text -

NHibernate1

unread,
Jul 19, 2010, 2:15:18 AM7/19/10
to nhusers
Hi All,

Thanks for the responses.

Updates to this post:

@Frans- I have double checked the ODP.NET version and OS versions they
are compatible.i.e. Win XP 32-bit & ODP.NET 32.bit 11g.

@Allan- Thank you for leting me know additional details on this
exception raising from Visual Studio Environment. But i observed this
exception on production env.

As a note this error is observed intermitently but not always.

I am still trying hard to figure out what could be the real cause,
meanwhile if you have any thoughts please share with me.

Thanks.

On Jul 16, 6:02 pm, "allan.ritc...@gmail.com"
> > > > >http://groups.google.com/group/nhusers?hl=en.-Hidequoted text -
>
> > > > - Show quoted text -
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "nhusers" group.
> > > To post to this group, send email to nhu...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > nhusers+u...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -

Frans Bouma

unread,
Jul 19, 2010, 3:04:33 AM7/19/10
to nhu...@googlegroups.com
> Updates to this post:
>
> @Frans- I have double checked the ODP.NET version and OS versions they are
> compatible.i.e. Win XP 32-bit & ODP.NET 32.bit 11g.
>
> @Allan- Thank you for leting me know additional details on this exception
> raising from Visual Studio Environment. But i observed this exception on
> production env.
>
> As a note this error is observed intermitently but not always.
>
> I am still trying hard to figure out what could be the real cause,
meanwhile
> if you have any thoughts please share with me.

As you're using Oracle in production, you likely have a support
contract with Oracle. Please consult Oracle about the exception, it might be
they can patch it.

FB

> > > > > > sionImp-l

Reply all
Reply to author
Forward
0 new messages