You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
The, Intercept method is already there which invokes the target method and and tries to get the return value from within the intercepted method:
public object Intercept(IInvocationInfo info)
{
var methodName = info.TargetMethod.Name;
Console.WriteLine("method '{0}' called", methodName);
// Replace the input parameter with 42
var result = info.TargetMethod.Invoke(info.Target, new object[]{42});
//Expecting to get the return value correctly from the target method.
return result;
//The return value is always null or equivalent (0 here)
}
Unfortunately, the return value from the target method invocation (info.TargetMethod.Invoke()) is always null or equivalent (0 here). So, when I try to postweave some of my existing dlls in a project, the project fails to run (Cause, the methods calls no longer return any value after post-weaving).
Using a reflector, I took a look at the post weaven Pay() method, after modifying the Pay() as returning an int. There I found the following codes, along with the injected codes
... int amount = wage; this._checkingAccount.Deposit(amount);
Console.WriteLine("Paid {0} units", wage);
int num2 = wage;
....
return (int) obj2;
//I've found that, the obj2 is never assigned with a value in the post weaven codes and hence, the postweaven methods always return null. This may give you some clue.
Please note that, the First version of LinFu.AOP was able to return the correct value from the postweaven intercepted methods (It had other issues though). So, I hope this issue should also be an easy fix.
Thanks
Comments
The text was updated successfully, but these errors were encountered:
The intercepted method in the sample interception program always returns null (Or, equivalent), no matter what actual value the method returns.
Let's change the Pay() method of Employee class to return an int
public int Pay(int wage)
{
}
The, Intercept method is already there which invokes the target method and and tries to get the return value from within the intercepted method:
public object Intercept(IInvocationInfo info)
{
}
Unfortunately, the return value from the target method invocation (info.TargetMethod.Invoke()) is always null or equivalent (0 here). So, when I try to postweave some of my existing dlls in a project, the project fails to run (Cause, the methods calls no longer return any value after post-weaving).
Using a reflector, I took a look at the post weaven Pay() method, after modifying the Pay() as returning an int. There I found the following codes, along with the injected codes
... int amount = wage; this._checkingAccount.Deposit(amount);
Console.WriteLine("Paid {0} units", wage);
int num2 = wage;
....
return (int) obj2;
//I've found that, the obj2 is never assigned with a value in the post weaven codes and hence, the postweaven methods always return null. This may give you some clue.
Please note that, the First version of LinFu.AOP was able to return the correct value from the postweaven intercepted methods (It had other issues though). So, I hope this issue should also be an easy fix.
Thanks
Comments
The text was updated successfully, but these errors were encountered: