我收到有关我们的实时环境中罕见且间歇性错误的报告。我尝试重现它并没有成功,错误本身就是一个小谜。除此之外,它似乎涉及企业库跟踪(我们使用的是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)的输入为null。
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");
}
}
答案 0 :(得分:1)
此问题似乎也是以前版本中E-Lib的已知错误。
称为:从多个线程使用日志记录AB时出现未处理的异常。
“潜在的问题是,在.NET 2.0 RTM中,如果在创建子项时存在这样的堆栈,则父子线程的操作堆栈与其子项共享。”
在这里阅读更多内容: http://entlib.codeplex.com/workitem/9592
很难建议一个通用的解决方案,因为它非常依赖于你的应用程序的架构。