PDA

View Full Version : AccessViolationException : Attempted to read or write protected memory.


jd78
12-19-2006, 02:47 PM
I am using the following advice to log method invocations.

public class LoggingBeforeAdvice : IMethodBeforeAdvice
{
private static ILog _log;
#region IMethodBeforeAdvice Members
public void Before(MethodInfo method, object[] args, object target)
{
if (_log == null)
_log = LogManager.GetLogger(method.DeclaringType);
string arguments = string.Empty;
if (args != null)
foreach (object arg in args)
{
try
{
arguments += arg.ToString() + ", ";
}
catch (Exception)
{}
}

_log.Info(method.Name + "Begin: " + arguments);
}

This works until I am passing variables by reference, at which point I get an error like the following:

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

This occurs at the line in the try/catch block. Crazy part is that the try/catch block above FAILS to catch this error. :confused: I was hoping I could just catch and ignore, but it seems not. Any thoughts? I am using Spring 1.0.2, with .net 2.0.

Bruno Baia
01-02-2007, 01:25 AM
Hi,

Have you tried using the latest Spring .NET 1.1 P3 ?


Bruno

jd78
01-02-2007, 07:52 PM
Hi,

Have you tried using the latest Spring .NET 1.1 P3 ?


Bruno

Yes Bruno, I did just try this w/ the latest Spring release. Same error.

Bruno Baia
01-03-2007, 03:04 AM
This works until I am passing variables by reference, at which point I get an error like the following:


Spring.Aop does not support ref/out parameters atm.


Cheers,
Bruno