2014-10-16 5 views
0

로깅 프로젝트에서 작업합니다. 데이터베이스의 메서드 매개 변수 값을 저장하고 싶습니다. 이 값들은 어떻게 얻을 수 있습니까? FirstChanceException 이벤트에서 "Test"메서드의 매개 변수 값을 가져 오려고합니다.C에서 메소드 On의 값 가져 오기 예외 #

class Program 
{ 
    private static void Main(string[] args) 
    { 
     AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException; 

     Test(100); 
    } 

    private static void Test(int i) 
    { 
     throw new OverflowException(); 
    } 

    private static void CurrentDomain_FirstChanceException(object sender, 
     System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e) 
    { 
     //I Want To Get Parameter Value of Test Method 
    } 
} 
+0

여기에 관해서 많은 다른 질문은 ... 할 수 없습니다. –

+0

가능한 중복 [.NET에서 호출 스택의 각 프레임에 대한 매개 변수 값을 가져올 수 있습니까?] (http://stackoverflow.com/questions/819576/is-it-possible-to-get-parameters-values- 각 프레임 인 - 콜 - 스택 - 인 - 넷 (net-in-call-in-call) – Dirk

답변

1

당신은 PostSharp으로 작업을 수행 할 수 있습니다

[Serializable] 
public class ExceptionPolicyAttribute : OnExceptionAspect 
{ 
    public override void OnException(MethodExecutionArgs args) 
    { 
     Guid guid = Guid.NewGuid(); 

     Trace.TraceError("Exception {0} handled by ExceptionPolicyAttribute: {1}", 
      guid, args.Exception.ToString()); 

     throw new InternalException( 
      string.Format("An internal exception has occurred. Use the id {0} " + 
      "for further reference to this issue.", guid)); 
    } 
} 

매개 변수 MethodExecutionArgs는 실패 메소드 호출로 전달 된 매개 변수 값이 포함되어 있습니다.

관련 문제