C# 获取引发异常的方法的参数名称和值
我有两个带代码的类C# 获取引发异常的方法的参数名称和值,c#,exception-handling,postsharp,C#,Exception Handling,Postsharp,我有两个带代码的类 [ExceptionAspect] public class BaseService { public void Method1(string email) { new BusinessClass().Method2(1, email, false); } } public class BusinessClass { public void Method2(int count, string email, bool ignor
[ExceptionAspect]
public class BaseService
{
public void Method1(string email)
{
new BusinessClass().Method2(1, email, false);
}
}
public class BusinessClass
{
public void Method2(int count, string email, bool ignoreCase)
{
throw new NotImplementedException();
}
}
我的exception aspect类有以下代码,使用这些代码,我能够获取Method1的参数名称和值,而不是Method2
[Serializable]
public class ExceptionAspect : OnExceptionAspect
{
public override void OnException(MethodExecutionArgs eventArgs)
{
object[] args = null;
if (eventArgs.Arguments != null)
args = eventArgs.Arguments.ToArray();
var parameters = eventArgs.Method.GetParameters();
}
}
现在,我想获取并保存异常目标站点的方法参数名称和值,即方法名称Method2的count=1、email=email和ignoreCase=false。将该属性添加到BusinessClass
[ExceptionAspect]
public class BusinessClass