eek: Attempted to read or write protected memory....

S

spacehopper_man

ok - C# contractor on first contract getting this bad boy:

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

I see this intermittantly (maybe every 100 requests or so) in an
ASP.NET 2.0 application running on Windows Server 2003 EE.

It appears to occur at different locations in the code every time I've
seen it.

It happens in both Debug and Release configurations I think.

The app is relatively large, and will be tough to prune down to get
closer to the problem.

Once the exception has been thrown once then all applications in that
process

Any suggestions? - maybe someone can suggest a way of getting closer to
the problem (I can catch the Exception).

I suspect it *could* be related to the fact that we're using Microsoft
XML, v4.0 (MSXML2) - anyone have any comments on that?

yours desperately,
Oli.
 
W

Willy Denoyette [MVP]

| ok - C# contractor on first contract getting this bad boy:
|
| "Attempted to read or write protected memory. This is often an
| indication that other memory is corrupt."
|
| I see this intermittantly (maybe every 100 requests or so) in an
| ASP.NET 2.0 application running on Windows Server 2003 EE.
|
| It appears to occur at different locations in the code every time I've
| seen it.
|
| It happens in both Debug and Release configurations I think.
|
| The app is relatively large, and will be tough to prune down to get
| closer to the problem.
|
| Once the exception has been thrown once then all applications in that
| process
|
| Any suggestions? - maybe someone can suggest a way of getting closer to
| the problem (I can catch the Exception).
|
| I suspect it *could* be related to the fact that we're using Microsoft
| XML, v4.0 (MSXML2) - anyone have any comments on that?
|
| yours desperately,
| Oli.
|

http://support.microsoft.com:80/kb/815112

Willy.
 
G

Guest

Not sure if its the cause for the issue but in .NET 2 you should be using the
System.XML namespace classes for XML manipulation.
The is an Access Violation which is caused by an invalid pointer in the
framework (not necesarily null but set to the wrong place). Are you using any
unsafe code in you app or passing ref arguments into/out of any unmanaged
components or libraries?


Ciaran O'Donnell
 
S

spacehopper_man

Ciaran said:
Not sure if its the cause for the issue but in .NET 2 you should be using the
System.XML namespace classes for XML manipulation.

yes - I'm aware of that - but at the client site that doesn't help me
much unfortunately.
The is an Access Violation which is caused by an invalid pointer in the
framework (not necesarily null but set to the wrong place). Are you using any
unsafe code in you app or passing ref arguments into/out of any unmanaged
components or libraries?

no - no unsafe code - well - non explicitly anyway - but I assume all
the MSXML2 stuff is unsafe under the hood....

....anyone got any idea how i can narrow down the problem at all ?

Oli.
 
W

Willy Denoyette [MVP]

|
| Ciaran O''Donnell wrote:
| > Not sure if its the cause for the issue but in .NET 2 you should be
using the
| > System.XML namespace classes for XML manipulation.
|
| yes - I'm aware of that - but at the client site that doesn't help me
| much unfortunately.
|
| > The is an Access Violation which is caused by an invalid pointer in the
| > framework (not necesarily null but set to the wrong place). Are you
using any
| > unsafe code in you app or passing ref arguments into/out of any
unmanaged
| > components or libraries?
|
| no - no unsafe code - well - non explicitly anyway - but I assume all
| the MSXML2 stuff is unsafe under the hood....
|
| ...anyone got any idea how i can narrow down the problem at all ?
|
| Oli.
|

Did you read my previous reply? MSXML is not supported in .NET applications,
the reason is that it has it's own garbage collecter and a threading model
that isn't handled by the CLR interop layer. You have to use System.xml in
managed code.


Willy.
 
S

spacehopper_man

Willy said:
|
| Ciaran O''Donnell wrote:
| > Not sure if its the cause for the issue but in .NET 2 you should be
using the
| > System.XML namespace classes for XML manipulation.
|
| yes - I'm aware of that - but at the client site that doesn't help me
| much unfortunately.
|
| > The is an Access Violation which is caused by an invalid pointer in the
| > framework (not necesarily null but set to the wrong place). Are you
using any
| > unsafe code in you app or passing ref arguments into/out of any
unmanaged
| > components or libraries?
|
| no - no unsafe code - well - non explicitly anyway - but I assume all
| the MSXML2 stuff is unsafe under the hood....
|
| ...anyone got any idea how i can narrow down the problem at all ?
|
| Oli.
|

Did you read my previous reply? MSXML is not supported in .NET applications,
the reason is that it has it's own garbage collecter and a threading model
that isn't handled by the CLR interop layer. You have to use System.xml in
managed code.


Willy.

Thanks Willy - yes I did see your mail - unfortunately it'll be a large
job to migrate away from MSXML to System.Xml.

Any idea if I MSXML 6 will help? - in fact I'm struggling to even use
MSXML6 at all as when I add a reference to the COM object I get:

Warning 3 Cannot find wrapper assembly for type library "MSXML2".

thanks again,
Oli.
 
M

Marc Gravell

If I figure correctly, the "wrapper assembly" issue appears to be (on
my machine at least) because of the PIA that SqlServer uses...

If you run tlbimp to produce your own interop assembly, and use that,
then it appears to work with the MSXML2 namespace. Alterantively try
using the PIA; for me it is here:
"C:\Program Files\Microsoft SQL
Server\90\DTS\Binn\Microsoft.SQLServer.msxml6_interop.dll"
I don't know if there are any re-distribution issues with this PIA.

Also note that the previous "compatibility" claim may relate more to
the schemas than the code - but if SqlServer wants a PIA for it, then
you could argue that it might just work.

Marc
 
M

Marc Gravell

Note also that the namespace changes (find/replace) if you use the PIA:

Microsoft.SqlServer.MSXML6.DOMDocument doc = new
Microsoft.SqlServer.MSXML6.DOMDocument();
doc.loadXML("somePath");
Console.WriteLine(doc.xml);

I realise that in a consultancy capacity the gig is often just "fix
it", but I would again repeat that it would be preferable to use
System.Xml.

Marc
 
S

spacehopper_man

Thanks very much - I can build my project at least with the sql server
msxml6 - no idea yet whether it'll fix the issue though.

....will probably convert a bunch of stuff to System.Xml as suggested

regards,
Oli.
 
M

Marc Gravell

Be sure to let us know how it goes... I'm confident others will be
interested in how MSXML6 stacks up...

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top