HI,
I'm using PostSharp to log entry and exit to every method in my Application assembly. This assembly is strongly named, versioned and registered in the GAC.
It is then shared by 2 web service projects hosted in separate Virtual Directories inside IIS. When the OnEntry/OnExit method of the interceptor is invoked by WebServiceProject1 it works fine, however when they are then invoked by WebServiceProject2, the MethodExecutionEventArgs.Method value passed into the interceptor seems to be null and I get a NullReferenceException.
If you restart IIS and invoke the web service projects in the order WebServiceProject2, WebServiceProject1 then again the first one to invoke works, and the other throws a NullReferenceException in the same way. The code is shown below:
[Serializable]
[Log(AttributeExclude = true)]
[AttributeUsage(AttributeTargets.All)]
public sealed class LogAttribute : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionEventArgs eventArgs)
{
IoC.Resolve<ILogger>().WriteMethodEntry(eventArgs.Method, eventArgs.GetReadOnlyArgumentArray());
}
public override void OnExit(MethodExecutionEventArgs eventArgs)
{
IoC.Resolve<ILogger>().WriteMethodExit(eventArgs.Method, eventArgs.ReturnValue);
}
}
Interestingly, if I remove the assembly from the GAC and make the webservice projects run off the \bin subdirectory copy, it works fine. I don't want to do this however as another part of the application relies on the assemblies being in the GAC, and I don't want lots of different versions of the same DLL in different places.
It is similar to the issue described here : http://generatedbyatool.net/content/post/2009/07/27/PostSharp-Bug-or-How-To-Recycle-Your-Own-App-Pool.aspx but there are obvious differences.
Anyone got any ideas or advice? I'm going to try to build a standalone application to prove this today.
Stoo