我收到了关于我们的实时环境中出现罕见且间歇性错误的报告。我试图重现它没有成功,而且错误本身有点神秘。除此之外,它似乎涉及到企业库跟踪(我们使用的是 5.0 版)——总而言之,有点痛苦。这发生在 Windows Sever 2008 上,应用程序位于 .Net Framework 4.0 (WPF) 上。
错误消息和堆栈跟踪如下:
ArgumentNullException: Value cannot be null. Parameter name: category
<StackTrace>
Server stack trace:
at Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry.BuildCategoriesCollection(String category)
at Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.WriteTraceMessage(String message, String entryTitle, TraceEventType eventType)
at Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.WriteTraceEndMessage(String entryTitle)
at Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.Dispose()
at TestApplication.ViewModelTest.<UpdateUsers>d__1a.MoveNext()
Exception rethrown at [0]:
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.<SetException>b__1(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
</StackTrace>
任何人都可以阐明可能导致这种情况的原因吗?
编辑:我没有修改 LogEntry.BuildCategoriesCollection。BuildCategoriesCollection(String category) 方法的输入为空。
UpdateUsers 方法如下:
async void UpdateUsers()
{
Processing = true;
using (traceMgr.StartTrace("Trace"))
using (var engine = new EngineClient())
{
Users = new List<UserMasterDataModel> { _blankUser };
var users = await engine.GetPossibleTagsTask(SelectedOutcomeId, _queue.SystemCd, _queue.QueueCd);
Users.AddRange(users);
}
if (SelectedUser != _blankUser)
{
// If null user selected then initialize to the case's tag, otherwise try to find the previously selected UserName
var userNameToFind = SelectedUser == null ? _details.TagTo : SelectedUser.UserName;
SelectedUser = Users.FirstOrDefault(user => user.UserName == userNameToFind) ?? _blankUser;
OnPropertyChanged("SelectedUser");
}
}