2015-08-08 15 views
5

Bir istemci Web Api'ye çağrıları kullandığımda bir hata meydana geliyor. Sorun, geri döneceğim yığın izinin biraz okunamaması, satır numaralarının olmaması, böylece nereye bakacağımı bilmiyorum. Bu bir Json cevabı olarak iade ediliyor.Asp.Net Web Api'den Uygun Yığın İzleme Async/Görev çağrıları

"message": "An error has occurred.", 
"exceptionMessage": "Object reference not set to an instance of an object.", 
"exceptionType": "System.NullReferenceException", 
"stackTrace": " at WakeSocial.Gateway.WebApi.Host.Controllers.NotificationsController.<Response>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()" 
} 

hata yüzden daha uygun sorunu ayıklamaya olabilir oluştu hat sayısını döndürmek için web API konfigürasyon dosyasında ki bir yolu var mı?

mesele burada kaplıydı: Stack traces with async/await

Şu anda .Net 4.5 usng ediyorum henüz hatalar hala bu şekilde outputted olsun.

+0

API'ı hata ayıklayabilir misiniz? Yapabilirseniz kolayca bir "NullReferenceException" arayabilirsiniz. –

+2

@JoelDean: WakeSocial.Gateway.WebApi.Host.Controllers.NotificationsController. d__7.MoveNext() ',' NotificationsController.Response 'eyleminde olduğu anlamına gelir. Eylem, izlemek için bir satır numarasına ihtiyacınız olacak kadar uzun ve karmaşık mı? –

cevap

0

I, örneğin özel durumlar içinde yığın izleme bilgilerini saklayan bir uzantı, ım kullanma, orijinal kod: okunabilir yığın izleme

try{  
    await NestedAsyncOperation(); 
}catch(NullReferenceException e){ 
    Debug.WriteLine(e) 
} 

:

try{  
    await NestedAsyncOperation().Trace(); 
}catch(Exception e){ 
    e.Catch((NullReferenceException ex) => { 
    Debug.WriteLine(e); 
    }).RethrowUnhandled(); 
} 

ve çıkış olacak hattı ile yığın izleme içerir sayılar. Daha fazlasını görün https://github.com/ilio/AsyncStackTrace/blob/master/UnitTests/AsyncStackTraceExtensionUnitTest.cs

İlgili konular