我的应用程序使用的是EF 6.1.2。我使用autofac将我的datacontext注册为单个实例。延迟加载已启用,它是代码优先的数据库设计。
我最近收到了很多旧系统(6岁以上)用户的错误日志。即使在我的旧戴尔核心独奏1.2 ghz和2gb ram运行Windows 7上,我也无法重复错误。)
以下是异常消息。它们略有不同,但似乎都出现在自定义ui值转换器中。
11/10/2015 14:13:01::Error|MFR.UI.Bootstrap.MfrBootstrapper|Stack Trace: at System.Data.Entity.Core.Objects.ObjectContext.EnsureContextIsEnlistedInCurrentTransaction[T](Transaction currentTransaction, Func`1 openConnection, T defaultValue)
at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable`1 sequence)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
at MFR.UI.Converters.EmployeeDisplayNameValueConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
at Infragistics.Windows.DataPresenter.Field.ConvertValue(Object value, DataRecord record)
at Infragistics.Windows.DataPresenter.DataRecord.GetCellValue(Field field, Boolean useConverter)
at Infragistics.Windows.DataPresenter.DataRecord.GetCellValue(Field field, CellValueType cellValueType)
at Infragistics.Windows.DataPresenter.CellValuePresenter.get_Value()
at Infragistics.Windows.DataPresenter.CellValuePresenter.InitializeCellLevelSettings(DataRecord newRecord, DataRecord oldRecord, Field newField, Field oldField, Boolean isWithinRecord)
at Infragistics.Windows.DataPresenter.CellValuePresenter.InitializeField(Field newField, Field oldField)
at Infragistics.Windows.DataPresenter.CellValuePresenter.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.InitializeCellElement(Control element, Field field, Record record, Boolean isHeader)
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.InitializeCellElement(Control element, Field field, Nullable`1 isMouseOverCellArea)
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.CreateCellElement(Int32 index, Field field, Boolean useCellPresenter, Nullable`1 isMouseOverCellArea)
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.VerifyCellsInView(Size elementSize)
at Infragistics.Windows.DataPresenter.VirtualizingDataRecordCellPanel.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
... more of the same
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
名为:
的值转换器public class EmployeeDisplayNameValueConverter :
{
protected readonly Func<IDataContext> Repo;
protected EmployeeDisplayNameValueConverter()
{
Repo = IoC.Get<Func<IDataContext>>();
}
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}
if (value is string)
{
{
var key = value.ToString();
var found = Repo.Invoke().Employees.FirstOrDefault(e => e.Id == key);
if (found == null)
{
return string.Empty;
}
return string.Format("{0}, {1} {2}", found.LastName, found.FirstName, found.MiddleInitial);
}
}
}
}
关于我可以研究什么的任何想法或建议?如上所述,我自己不能在本地重复这个问题,这使得它变得更加困难 - 但这似乎只是一个老问题&#34;机器。