EnterpriseLibrary错误

我收到有关我们的实时环境中罕见且间歇性错误的报告。 我试图重现它并没有成功,错误本身就是一个小谜。 除此之外,它似乎涉及企业库跟踪(我们使用的是5.0版本) – 总而言之,有点痛苦。 这是在Windows Sever 2008上发生的,应用程序在.Net Framework 4.0(WPF)上。

错误消息和堆栈跟踪如下:

ArgumentNullException: Value cannot be null. Parameter name: category  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()  

任何人都可以解释可能导致这种情况的原因吗?

编辑:我没有修改LogEntry.BuildCategoriesCollection。 方法BuildCategoriesCollection(String category)的输入为null。

UpdateUsers方法如下:

 async void UpdateUsers() { Processing = true; using (traceMgr.StartTrace("Trace")) using (var engine = new EngineClient()) { Users = new List { _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"); } } 

这个问题似乎也是以前版本中E-Lib的一个已知错误。

称为:从多个线程使用日志记录AB时出现未处理的exception。

“潜在的问题是,在.NET 2.0 RTM中,如果在创建子节点时存在这样的堆栈,则父线程的操作堆栈与其子节点共享。”

点击此处了解更多信息: http : //entlib.codeplex.com/workitem/9592

很难建议一个通用的解决方案,因为它非常依赖于您的应用程序的体系结构。