Пользователь
Регистрация: 14.05.2009
Сообщений: 44
|
Необработанное исключение типа "System.NullReferenceException" в PresentationFramework.dll
Всем добрый день!
Имею WPF форму с DataGrid одно из полей которого содержит ComboBox
Код:
<Grid.Resources>
<ui:TypeToColorConverter x:Key="TypeToColor"/>
</Grid.Resources>
<DataGrid Grid.Row="0" Name="ListComponents" AutoGenerateColumns="False" GridLinesVisibility ="All" IsReadOnly="True" ItemsSource="{Binding ListComponents}">
<DataGrid.Columns>
<DataGridTextColumn Header="№" Binding="{Binding Path=Id}"/>
<DataGridTextColumn Header="Штрихкод" Binding="{Binding Path=BarCode}"/>
<DataGridTemplateColumn Header="Наименование" MinWidth="200" SortMemberPath="Name">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="services:IListComponentsElement">
<ComboBox Name ="comboBox" ItemsSource="{Binding Path=StrList}" SelectedValue ="{Binding Path=Name}" SelectionChanged="comboBoxChanged" Background="{Binding Path = TypeValue, Converter={StaticResource TypeToColor}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="Background" Value="{Binding Path = TypeValue, Converter={StaticResource TypeToColor}}"/>
</Style>
</DataGrid.RowStyle>
</DataGrid>
Вроде как все замечательно работает.
Но в определенный момент при разнообразных манипуляциях с DataGrid вылетает эррор в точке входа в программу:
Цитата:
System.NullReferenceException не обработано
HResult=-2147467261
Message=Ссылка на объект не указывает на экземпляр объекта.
Source=PresentationFramework
StackTrace:
в System.Windows.Controls.DataGridRow .RestoreAttachedItemValue(Dependenc yObject objectWithProperty, DependencyProperty property)
в System.Windows.Controls.DataGridRow .SyncProperties(Boolean forcePrepareCells)
в System.Windows.Controls.DataGridRow .PrepareRow(Object item, DataGrid owningDataGrid)
в System.Windows.Controls.DataGrid.Pr epareContainerForItemOverride(Depen dencyObject element, Object item)
в System.Windows.Controls.ItemsContro l.MS.Internal.Controls.IGeneratorHo st.PrepareItemContainer(DependencyO bject container, Object item)
в System.Windows.Controls.Virtualizin gStackPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)
в System.Windows.Controls.Virtualizin gStackPanel.AddContainerFromGenerat or(Int32 childIndex, UIElement child, Boolean newlyRealized, Boolean isBeforeViewport)
в System.Windows.Controls.Virtualizin gStackPanel.MeasureChild(IItemConta inerGenerator& generator, IContainItemStorage& itemStorageProvider, IContainItemStorage& parentItemStorageProvider, Object& parentItem, Boolean& hasUniformOrAverageContainerSizeBee nSet, Double& computedUniformOrAverageContainerSi ze, Double& computedUniformOrAverageContainerPi xelSize, Boolean& computedAreContainersUniformlySized , IList& items, Object& item, IList& children, Int32& childIndex, Boolean& visualOrderChanged, Boolean& isHorizontal, Size& childConstraint, Rect& viewport, VirtualizationCacheLength& cacheSize, VirtualizationCacheLengthUnit& cacheUnit, Boolean& foundFirstItemInViewport, Double& firstItemInViewportOffset, Size& stackPixelSize, Size& stackPixelSizeInViewport, Size& stackPixelSizeInCacheBeforeViewport , Size& stackPixelSizeInCacheAfterViewport, Size& stackLogicalSize, Size& stackLogicalSizeInViewport, Size& stackLogicalSizeInCacheBeforeViewpo rt, Size& stackLogicalSizeInCacheAfterViewpor t, Boolean& mustDisableVirtualization, Boolean isBeforeFirstItem, Boolean isAfterFirstItem, Boolean isAfterLastItem, Boolean skipActualMeasure, Boolean skipGeneration, Boolean& hasBringIntoViewContainerBeenMeasur ed, Boolean& hasVirtualizingChildren)
в System.Windows.Controls.Virtualizin gStackPanel.MeasureOverrideImpl(Siz e constraint, Nullable`1& lastPageSafeOffset, List`1& previouslyMeasuredOffsets, Nullable`1& lastPagePixelSize, Boolean remeasure)
в System.Windows.Controls.Virtualizin gStackPanel.MeasureOverride(Size constraint)
в System.Windows.Controls.Primitives. DataGridRowsPresenter.MeasureOverri de(Size constraint)
в System.Windows.FrameworkElement.Mea sureCore(Size availableSize)
в System.Windows.UIElement.Measure(Si ze availableSize)
в System.Windows.ContextLayoutManager .UpdateLayout()
в System.Windows.ContextLayoutManager .UpdateLayoutCallback(Object arg)
в System.Windows.Media.MediaContext.F ireInvokeOnRenderCallbacks()
в System.Windows.Media.MediaContext.R enderMessageHandlerCore(Object resizedCompositionTarget)
в System.Windows.Media.MediaContext.R enderMessageHandler(Object resizedCompositionTarget)
в System.Windows.Threading.ExceptionW rapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
в System.Windows.Threading.ExceptionW rapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
в System.Windows.Threading.Dispatcher Operation.InvokeImpl()
в System.Threading.ExecutionContext.R unInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.ExecutionContext.R un(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.ExecutionContext.R un(ExecutionContext executionContext, ContextCallback callback, Object state)
в System.Windows.Threading.Dispatcher Operation.Invoke()
в System.Windows.Threading.Dispatcher .ProcessQueue()
в System.Windows.Threading.Dispatcher .WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
в MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
в MS.Win32.HwndSubclass.DispatcherCal lbackOperation(Object o)
в System.Windows.Threading.ExceptionW rapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
в System.Windows.Threading.ExceptionW rapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
в System.Windows.Threading.Dispatcher .LegacyInvokeImpl(DispatcherPriorit y priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
в MS.Win32.HwndSubclass.SubclassWndPr oc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
в MS.Win32.UnsafeNativeMethods.Dispat chMessage(MSG& msg)
в System.Windows.Threading.Dispatcher .PushFrameImpl(DispatcherFrame frame)
в System.Windows.Application.RunDispa tcher(Object ignore)
в System.Windows.Application.RunInter nal(Window window)
в Alarm.TrashReception.App.EntryPoint .Main() в c:\C#\Telemetria.Net 3.0\src\Clients.Alarm\TrashReceptio n\App\EntryPoint.cs:строка 34
...............................
InnerException:
|
Какой-то закономерности при этом я не уловил.
На сайте мелкомягких ( https://support.microsoft.com/en-us/kb/2362055) написано (как я понял), что это проблема PresentationFramework. Статья 2010 года, неужели с тех пор не исправили?
Подскажите как быть и что делать. Может кто-то сталкивался с такой проблемой
|