2015-08-14 22 views
0

我有一個測試MCV Api,它只是返回傳遞給它的主體和標題內容。當我嘗試並調用它,我得到以下異常:MVC Api調用性能計數器異常

{ 
    "Message": "An error has occurred.", 
    "ExceptionMessage": "The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.", 
    "ExceptionType": "System.InvalidOperationException", 
    "StackTrace": " 
     at System.Diagnostics.PerformanceCounter.InitializeImpl() 
     at System.Diagnostics.PerformanceCounter.set_RawValue(Int64 value) 
     at PerfIt.Handlers.CurrentConcurrentCountHandler.<>c__DisplayClass6_0.<BuildCounters>b__0() 
     at System.Lazy`1.CreateValue() 
     --- End of stack trace from previous location where exception was thrown --- 
     at System.Lazy`1.get_Value() 
     at PerfIt.Handlers.CurrentConcurrentCountHandler.OnRequestStarting(IDictionary`2 contextBag, PerfItContext context) 
     at PerfIt.Handlers.CounterHandlerBase.OnRequestStarting(IDictionary`2 contextBag) 
     at PerfIt.SimpleInstrumentor.BuildContexts() 
     at PerfIt.SimpleInstrumentor.<InstrumentAsync>d__4.MoveNext() 
     --- End of stack trace from previous location where exception was thrown --- 
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
     at PerfIt.PerfitClientDelegatingHandler.<SendAsync>d__19.MoveNext() 
     --- End of stack trace from previous location where exception was thrown --- 
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
     at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()" 
} 

在如何解決這個問題的任何援助將不勝感激全盤損失。從我所做的搜索結果中可以看出,這與signalR有關,並且在這裏沒有任何影響。注意:這隻發生在解決方案中的一些控制器上,其他我能夠調試的罰款。

回答

0

對於任何人在將來看到這一點。這隻發生在調試模式下。我能夠通過註釋掉WebApiConfig文件中的config.MessageHandlers.Add(新的PerfitClientDelegatingHandler(「」))行來繞過此問題。