PDA

View Full Version : Debugging with AOP - step into method problem


dziegel
03-27-2007, 02:00 PM
Hello,

I've created a class with several methods that are intercepted via AOP. When I debug my code, VisualStudio 2003 does not step into the method any more when debugging the code.

e.g. when I debug this:

object.someMethodCall();

is stepped OVER instead of INTO when someMethodCall() is an intercepted call.
I can imagine why this happens, it's the runtime code generated by spring where VS has no sources for, but is there any way to step into the function anyway?

The general problem I have with this is that AOP cleanly separates functionalities from each other (big advantage), but when I debug my code, I do not see the real control flow any more (bigger disadvantage?)...

Thanks a lot for any hints,
Dirk

Bruno Baia
03-27-2007, 03:37 PM
Hi,

Looks like a side effect due to recent use of DynamicReflection in AOP.
Are you using debug or release builds ?


Bruno

Bruno Baia
03-28-2007, 10:29 AM
Hi,

I revert changes to use standard reflection in spring.Aop until we resolve the problem with dynamic reflection.
give a try to the latest nightly build (http://www.springframework.net/downloads/nightly/).


Bruno

dziegel
03-30-2007, 10:09 AM
Hello Bruno,

thank you for your quick reply. I just tried the latest nightly build, but the problem persists. Let me clarify it to be sure we talk about the same issue.
In the code below, I cannot step INTO the "someInstance.someMethod()" call. I can of course place breakpoints in it and VS2003 will stop there, but for virtual methods, I usually don't know in advance where they are mapped to. So I would like to step into the method to debug it. I would even like to see the Before() call to I clearly see at runtime that this is an intercepted method.
In large projects, other developers will use my code and will usually not know that this is intercepted code.
Is there some way to achieve this?


using System;
using Spring.Context;
using Spring.Context.Support;
using Spring.Aop;
using System.Reflection;

namespace SpringDebugProblem
{
public class InterceptedClass
{
public virtual string someMethod(string someParameter)
{
return "SomeReturnValue";
}
};

public class BeforeAdvice : IMethodBeforeAdvice
{
public void Before(MethodInfo method, object[] args, object target)
{
Console.Out.WriteLine("Entering method: " + method.Name + target.ToString());
}
}

class SpringDebugProblem
{
[STAThread]
static void Main(string[] args)
{
IApplicationContext ctx = ContextRegistry.GetContext();
InterceptedClass someInstance = (InterceptedClass)ctx.GetObject ("theInterceptedClass");
someInstance.someMethod("someParameter"); // <---- Breakpoint here, step into method
}
}
}

<?xml version="1.0" encoding="UTF-8" ?>
<objects xmlns="http://www.springframework.net">
<object id="toBeInterceptedClass" type="SpringDebugProblem.InterceptedClass, SpringDebugProblem" />
<object id="theBeforeAdvice" type="SpringDebugProblem.BeforeAdvice, SpringDebugProblem" />
<object id="theInterceptedClass" type="Spring.Aop.Framework.ProxyFactoryObject">
<property name="Target" ref="toBeInterceptedClass" />
<property name="InterceptorNames">
<list>
<value>theBeforeAdvice</value>
</list>
</property>
</object>
</objects>

Bruno Baia
03-30-2007, 03:05 PM
Hi,

you right, we was not talking about the same issue. I've read the post too fast :)
I've tried to step into a proxied method in VS2003 with Spring.NET 1.0.2 and 1.1 P3 and got the same problem. On which version have you make it work ?
With VS2005 it works fine.

Maybe .NET 1.1 and VS2003 does not support the "step into" with a type defined in a dynamic assembly ?


Bruno

Aleks Seovic
03-30-2007, 07:28 PM
Hi Dirk,

This really has nothing to do with the Dynamic Reflection, but with the fact that you are trying to step into dynamically generated method and it looks like VS 2004 doesn't support that.

Try setting a break point within your advice and the target method that you want to step into. That should help.

- Aleks

Bruno Baia
03-30-2007, 08:42 PM
Hi Dirk,

This really has nothing to do with the Dynamic Reflection, but with the fact that you are trying to step into dynamically generated method and it looks like VS 2004 doesn't support that.

Try setting a break point within your advice and the target method that you want to step into. That should help.

- Aleks
Yep that's what I was trying to say with my own english words :)

dziegel
03-31-2007, 03:30 PM
Hello Bruno,

this is indeed a VS2003 Problem. I tried VS2005 and it workes perfectly. Thank your for your advice and for your time.

Greetings from Mannheim, Germany
Dirk