Сигнатура проблемы:
Имя события проблемы: CLR20r3<br>
Сигнатура проблемы 01: borejournals.exe<br>
Сигнатура проблемы 02: 1.0.0.0<br>
Сигнатура проблемы 03: 54ed6277<br>
Сигнатура проблемы 04: BoreJournals<br>
Сигнатура проблемы 05: 1.0.0.0<br>
Сигнатура проблемы 06: 54ed6277<br>
Сигнатура проблемы 07: 11b<br>
Сигнатура проблемы 08: 238(изначально было 1f2)<br>
Сигнатура проблемы 09: System.NullReferenceException<br>
Версия ОС: 6.1.7601.2.1.0.256.4<br>
Код языка: 1049<br>
Дополнительные сведения 1: 0a9e<br>
Дополнительные сведения 2: 0a9e372d3b4ad19135b953a78882e789<br>
Дополнительные сведения 3: 0a9e<br>
Дополнительные сведения 4: 0a9e372d3b4ad19135b953a78882e789<br>
На одном ресурсе нашел информацию, о том что сигнатура проблемы 07 - код который можно найти в IL коде. Метод в котором возникает ошибка
private void SampleBinding()
{
LayerGroupBox.DataContext = _journalStruct.InfoBore[_idBore].SoilLayer[_idLayer];
if (_journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample != null)
{
MessageBox.Show("Count = "+_journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample.Count());
if (_journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample.Count > 0)
{
MessageBox.Show("Count > 0 try to add samples into tabcontrol");
try
{
DataScrollViewer.DataContext = Analyzes; // проходит нормально
SoilTabControl.ItemsSource = _journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample; //крашится
}
catch (Exception exception)
{
MessageBox.Show("Crash, error: "+ exception.Message +
", source: " + exception.Source+
", site: " + exception.TargetSite);
}
}
}
InnerListView.ItemsSource = _journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilInner;
SoilsNameComboBox.ItemsSource = _classifier.Soilses;
SoilsCategoryComboBox.ItemsSource = _category;
//DataScrollViewer.DataContext = Analyzes;
}
Отлов Exception не происходит, 100% уверен что _journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample;
- не пустой.
Проблема возникает только на ПК без Visual Studio.
.Net Framework 4.0 и выше (на всех пк), проект строится под 4.0.
Пробовал выносить все библиотеки какие есть в проекте - локально к exe файлу приложения, результата нет..
при том на приложение работает на всех компах где есть .net 4.0/4.5 но обязательно присутствует visual studio, так же на 2 других без студии однако непонятно почему...
В прошлом году приложение работало на любом ПК, изменения вносились в код не пересекающийся с данным куском кода.
прилагаю найденные строки из IL по номеру кода 238
IL_0226: ldarg.2
IL_0227: castclass [PresentationFramework]System.Windows.Controls.CheckBox
IL_022c: ldarg.0
IL_022d: ldftn instance void BoreJournals.Frames.JourEditWindow::CheckedAnalyzes_onCheck(object, class [PresentationCore]System.Windows.RoutedEventArgs)
IL_0233: newobj instance void [PresentationCore]System.Windows.RoutedEventHandler::.ctor(object, native int)
IL_0238: callvirt instance void [PresentationFramework]System.Windows.Controls.Primitives.ToggleButton::add_Checked(class [PresentationCore]System.Windows.RoutedEventHandler)
IL_023d: nop
IL_023e: ldarg.2
IL_023f: castclass [PresentationFramework]System.Windows.Controls.CheckBox
IL_0244: ldarg.0
IL_0245: ldftn instance void BoreJournals.Frames.JourEditWindow::CheckedAnalyzes_onCheck(object, class [PresentationCore]System.Windows.RoutedEventArgs)
За код прошу по рукам не бить, писался до знания о MVVM, заранее спасибо всем кто сможет помочь!
UPD:
Message: Ссылка на объект не указывает на экземпляр объекта.;
Terminating: True;
Exception obj: System.NullReferenceException: Ссылка на объект не указывает на экземпляр объекта.
в BoreJournals.Frames.JourEditWindow.System.Windows.Markup.IStyleConnector.Connect(Int32 connectionId, Object target) в h:\Работа\BoreJournals\BoreJournals\Frames\JourEditWindow.xaml:строка 1307
в System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
в System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
в System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
в System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)
в System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)
в System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container)
в System.Windows.FrameworkElement.ApplyTemplate()
в System.Windows.FrameworkElement.MeasureCore(Size availableSize)
в System.Windows.UIElement.Measure(Size availableSize)
в System.Windows.Controls.Border.MeasureOverride(Size constraint)
в System.Windows.FrameworkElement.MeasureCore(Size availableSize)
в System.Windows.UIElement.Measure(Size availableSize)
в System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
в System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
в System.Windows.Controls.Grid.MeasureOverride(Size constraint)
в System.Windows.FrameworkElement.MeasureCore(Size availableSize)
в System.Windows.UIElement.Measure(Size availableSize)
в System.Windows.ContextLayoutManager.UpdateLayout()
в System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
в System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
в System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
в System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
в System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
в MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
в System.Windows.Threading.DispatcherOperation.InvokeImpl()
в System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
в System.Threading.ExecutionContext.runTryCode(Object userData)
в System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
в System.Windows.Threading.DispatcherOperation.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.DispatcherCallbackOperation(Object o)
в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
в MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
в System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
в MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
в MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
в System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
в System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
в System.Windows.Application.RunDispatcher(Object ignore)
в System.Windows.Application.RunInternal(Window window)
в System.Windows.Application.Run(Window window)
в System.Windows.Application.Run()
в BoreJournals.App.Main() в h:\Работа\BoreJournals\BoreJournals\obj\Debug\App.g.cs:строка 0
Выходит, что ошибка в Checked="CheckedAnalyzes_onCheck" Unchecked="CheckedAnalyzes_onCheck"
Сам шаблон
<ListView
MinHeight="400"
MaxHeight="500"
ItemsSource="{Binding ElementName=DataScrollViewer, Path=DataContext}"
Margin="2"
IsSynchronizedWithCurrentItem="True">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox
Grid.Column="0"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Checked="CheckedAnalyzes_onCheck"
Unchecked="CheckedAnalyzes_onCheck"
Margin="2">
<CheckBox.IsChecked>
<MultiBinding Converter="{StaticResource SetCheckListViewConverter}" Mode="OneWay">
<Binding Path="Analyze" />
<Binding ElementName="DataDocPanel" Path="DataContext"/>
</MultiBinding>
</CheckBox.IsChecked>
</CheckBox>
<TextBlock
Name="Gnd"
Grid.Column="1"
HorizontalAlignment="Stretch"
Margin="2"
Text="{Binding Path=Analyze, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
выходит что IL все же верно направил?
IL_0238: callvirt instance void [PresentationFramework]System.Windows.Controls.Primitives.ToggleButton::add_Checked(class [PresentationCore]System.Windows.RoutedEventHandler)
Ну и собственно сам метод в котором происходит крах:
private void CheckedAnalyzes_onCheck(object sender, RoutedEventArgs e)
{
try
{
if (SoilTabControl == null) return;
var index = SoilTabControl.SelectedIndex;
if (sender == null) return;
var cb = sender as CheckBox;
if (cb == null) return;
if (cb.DataContext == null) return;
var item = (Analyzes) cb.DataContext;
if (_journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample == null) return;
var analyzes = _journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample[index].SampleAnalyzes ?? (_journalStruct.InfoBore[_idBore].SoilLayer[_idLayer].SoilSample[index].SampleAnalyzes =
new ObservableCollection<Analyzes>());
if (cb.IsChecked == true)
{
if (!(analyzes.Any(soilse => soilse.Analyze == item.Analyze)))
{
analyzes.Add(item);
}
if (analyzes.Count == 0)
{
analyzes.Add(item);
}
}
else
{
foreach (var analyze in analyzes.Where(soilse => soilse.Analyze == item.Analyze))
{
analyzes.Remove(analyze);
break;
}
}
}
catch (Exception exception)
{
MessageBox.Show("Исключение при загрузке лабораторных анализов : "+exception.Message, "Внимание", MessageBoxButton.OK,
MessageBoxImage.Information);
}
}
Однако обернув все в try, catch ничего не получаю.. выходит что ошибка появляется при формировании шаблона в xaml?
Или проблема возникает из-за вложенности шаблонов, потому что у меня идет TabControl-> TabControl.Contenttemplate -> DataTemplate -> dockpanel -> dockpanel -> ListView -> ListView.ItemTemplate -> DataTemplate -> Grid -> CheckBox
Не могу понять как с этим бороться =/ ибо где-то работает, а где-то нет.
UPD 2: И действительно убрав
Checked="CheckedAnalyzes_onCheck"
Unchecked="CheckedAnalyzes_onCheck"
все отображается как нужно, но метод содержит важные действия в частности добавление отмеченных и удаление не отмеченных значений из списка в коллекции, проверяю на null все что можно, однако проблема не пропала =/
NullReferenceException
не ловится в вашем кэтче -- значит, он возникает не там. 238 -- это смещение внутри метода, который падает. 11b -- это токен падающего метода. Подпишитесь на событиеAppDomain.CurrentDomain.UnhandledException
и выведите куда-нибудь информацию об исключении (e.ExceptionObject.ToString()
), чтобы увидеть нормальный стектрейс. Ну и нам его покажите :).