EnterpriseLibrary错误 [英] EnterpriseLibrary Error
问题描述
我收到我们的生活环境中的稀有和间歇性的错误报告。我在试图重现它是不成功的,而错误本身就是一个谜轻微。再加上,这似乎是一些涉及到企业库跟踪(我们使用的是版本5.0) - 所有的一切,有点痛。这是在Windows Sever的2008发生的事情,应用程序是在.Net框架4.0(WPF)
该错误消息和堆栈跟踪如下:
ArgumentNullException:值不能为空。参数名:类
<&栈跟踪GT;
服务器堆栈跟踪:
在Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry.BuildCategoriesCollection(字符串类)
在Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.WriteTraceMessage(字符串消息,串entryTitle ,TraceEventType EVENTTYPE)
在Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.WriteTraceEndMessage(字符串entryTitle)在Microsoft.Practices.EnterpriseLibrary.Logging.Tracer.Dispose
()
在TestApplication.ViewModelTest 。&放大器; LT; UpdateUsers和放大器; GT d__1a.MoveNext()
异常的[0]重新抛出:; LT;
在System.Runtime.CompilerServices.AsyncVoidMethodBuilder&放SetException和放大器; GT;在System.Threading.QueueUserWorkItemCallback.WaitCallback_Context b__1(对象状态)
(对象状态)
在System.Threading.ExecutionContext.runTryCode(对象USERDATA)
在System.Runtime.CompilerServices.RuntimeHelpers。 ExecuteCodeWithGuaranteedCleanup(TryCode代码,CleanupCode backoutCode,用户数据对象)的System.Threading.ExecutionContext.RunInternal
(ExecutionContext中的ExecutionContext,ContextCallback回调,对象状态)在System.Threading.ExecutionContext.Run(ExecutionContext中的ExecutionContext,ContextCallback
回调,对象状态,布尔ignoreSyncCtx)
在System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()在System.Threading.ThreadPoolWorkQueue.Dispatch
()
在的System.Threading ._ThreadPoolWaitCallback.PerformWaitCallback()
< /堆栈跟踪>
有人能阐明什么可能导致此?
$任何光b $ b
编辑:
我没有修改LogEntry.BuildCategoriesCollection。该输入方法BuildCategoriesCollection(字符串类别)是空
的UpdateUsers方法如下:
异步无效UpdateUsers()
{
处理= TRUE;使用(traceMgr.StartTrace(跟踪))
使用(VAR发动机=新EngineClient())
{
用户
=新的List< UserMasterDataModel> {} _blankUser;
变种的用户=等待engine.GetPossibleTagsTask(SelectedOutcomeId,_queue.SystemCd,_queue.QueueCd);
Users.AddRange(用户);
}
如果(SelectedUser!= _blankUser)
{
//如果然后选择空用户初始化的情况下的标签,否则试图找到先前选定的用户名
VAR userNameToFind = SelectedUser == NULL? _details.TagTo:SelectedUser.UserName;
SelectedUser = Users.FirstOrDefault(用户=> user.UserName == userNameToFind)? _blankUser;
OnPropertyChanged(SelectedUser);
}
}
这。问题似乎是在以前的版本太多了E-库一个已知的bug。
被称为:从多个线程使用记录AB时未处理的异常
根本的问题是,在.NET 2.0 RTM如果由孩子们创建时存在这样的叠父线程的操作栈与它的孩子分享。
在这里阅读更多:
HTTP://entlib.codeplex .COM /工作项目/ 9592
很难提出一个通用的解决这个,因为它是非常依赖于你的应用程序的体系结构。
I'm receiving reports of a rare and intermittent error in our live environment. I have been unsuccessful in my attempts to reproduce it, and the error itself is a slight mystery. Add to that, it seems to be something involving Enterprise Library tracing (we're using version 5.0) - all in all, a bit of a pain. This is happening on Windows Sever 2008, application is on .Net Framework 4.0 (WPF).
The error message and the stack trace follow:
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>
Can anyone shed any light on what might be causing this?
EDIT: I'm not modifying LogEntry.BuildCategoriesCollection. The input to the method BuildCategoriesCollection(String category) is null.
The UpdateUsers method is as follows:
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");
}
}
This problem seem to be a known bug for E-Lib in previous versions too.
Known as: Unhandled exception when using the logging AB from multiple threads.
"The underlying issue is that in .NET 2.0 RTM a parent thread's operation stack was shared with its children if such a stack existed by the time the children were created."
Read more here: http://entlib.codeplex.com/workitem/9592
Hard to suggest a generic solution to this as it is very depends on the architecture of your app.
这篇关于EnterpriseLibrary错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!