Exception in ShowDialog from different Window - wpf
I have a custom Window I want to show, when an unhandled exception occurs. Something like this:
private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
try
{
e.Handled = true; // If e.Handled == false or error dialog will not show.
string errorMassage = ExceptionFormatter.FormatException(e.Exception)
var window = new FatalErrorWindow(errorMassage );
window.ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(errorMassage, "Program error", MessageBoxButton.OK);
}
Application.Current.Shutdown(-1);
}
In some situations the ShowDialog itself throws an exception, so I added a try/catch for that, and discovered that when ShowDialog is called, it seems as if .NET performs a full UpdateLayout cycle for a different window (the main window presumably?).
Now the problem is that if that cycle throws an exception during the Measure/Arrange phase, that is basically not possible to handle gracefully. Any attempt to show a pretty dialog will run into the same exception.
Does anyone have a suggestion how to fix/get around this?¨
EDIT: (In response to comment)
My concern is that I cannot try/catch anything to prevent this. ANY UI element - that being my own, a 3rd party or even a .NET element - in a completely unrelated part of the application, could throw a NullReferenceException in a Measure/Arrange method, and it is essentially uncatchable.
Below is a stacktrace which illustrates the problem.
at 3rdPartyVendor.UI.Xaml.Grid.GridDataRow.UpdateFixedRowState()
at
3rdPartyVendor.UI.Xaml.Grid.RowGenerator.EnsureRows(VisibleLinesCollection
visibleRows) at
3rdPartyVendor.UI.Xaml.Grid.VisualContainer.EnsureItems(Boolean
ensureColumns) at
3rdPartyVendor.UI.Xaml.Grid.VisualContainer.MeasureOverride(Size
constraint) at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Primitives\ScrollContentPresenter.cs:line
432 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1431
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV, Boolean& hasDesiredSizeUChanged) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1286
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1250
at System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 701 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
in
f:\dd\wpf\src\Framework\System\Windows\Controls\ScrollViewer.cs:line
1220 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Border.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Border.cs:line 245
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1431
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV, Boolean& hasDesiredSizeUChanged) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1286
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1250
at System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 701 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at 3rdPartyVendor.UI.Xaml.Grid.SfDataGrid.MeasureOverride(Size
availableSize) at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1431
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV, Boolean& hasDesiredSizeUChanged) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1286
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1250
at System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 701 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\ContentPresenter.cs:line
495 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
XXXXXX.Common.Controls.CachingPanel.MeasureOverride(Size
availableSize) in
F:\git\XXXXXXX\Source\XXXXXX.Common\Controls\CachingPanel.cs:line 84
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 441 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Border.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Border.cs:line 245
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\ContentPresenter.cs:line
495 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 441 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1431
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV, Boolean& hasDesiredSizeUChanged) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1286
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1250
at System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 701 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\ContentPresenter.cs:line
495 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 441 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\ContentPresenter.cs:line
495 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Border.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Border.cs:line 245
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1431
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV, Boolean& hasDesiredSizeUChanged) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1286
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1250
at System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 701 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 441 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\ContentPresenter.cs:line
495 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
XXXXXX.Common.Controls.CachingPanel.MeasureOverride(Size
availableSize) in
F:\git\XXXXXXX\Source\XXXXXX.Common\Controls\CachingPanel.cs:line 84
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1431
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV, Boolean& hasDesiredSizeUChanged) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1286
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1250
at System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 701 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\ContentPresenter.cs:line
495 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
XXXXXX.Common.Controls.CachingPanel.MeasureOverride(Size
availableSize) in
F:\git\XXXXXXX\Source\XXXXXX.Common\Controls\CachingPanel.cs:line 84
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 441 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Border.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Border.cs:line 245
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Control.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Control.cs:line 711
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 441 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1431
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV, Boolean& hasDesiredSizeUChanged) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1286
at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,
Size referenceSize, Boolean ignoreDesiredSizeU, Boolean
forceInfinityV) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 1250
at System.Windows.Controls.Grid.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Grid.cs:line 701 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element,
Size constraint) in f:\dd\wpf\src\Framework\MS\Internal\Helper.cs:line
547 at
System.Windows.Controls.ContentPresenter.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\ContentPresenter.cs:line
495 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Documents.AdornerDecorator.MeasureOverride(Size
constraint) in
f:\dd\wpf\src\Framework\System\Windows\Documents\AdornerDecorator.cs:line
129 at System.Windows.FrameworkElement.MeasureCore(Size
availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Controls.Border.MeasureOverride(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Controls\Border.cs:line 245
at System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4402
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.Window.MeasureOverrideHelper(Size constraint) in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 3497 at
System.Windows.Window.MeasureOverride(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 1881 at
System.Windows.FrameworkElement.MeasureCore(Size availableSize) in
f:\dd\wpf\src\Framework\System\Windows\FrameworkElement.cs:line 4323
at System.Windows.UIElement.Measure(Size availableSize) at
System.Windows.ContextLayoutManager.UpdateLayout() at
System.Windows.UIElement.UpdateLayout() at
System.Windows.Interop.HwndSource.SetLayoutSize() at
System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at System.Windows.Window.SetRootVisual() in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 2967 at
System.Windows.Window.SetRootVisualAndUpdateSTC() in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 2978 at
System.Windows.Window.SetupInitialState(Double requestedTop, Double
requestedLeft, Double requestedWidth, Double requestedHeight) in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 2942 at
System.Windows.Window.CreateSourceWindow(Boolean duringShow) in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 2679 at
System.Windows.Window.CreateSourceWindowDuringShow() in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 2532 at
System.Windows.Window.SafeCreateWindowDuringShow() in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 5643 at
System.Windows.Window.ShowHelper(Object booleanBox) in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 5743 at
System.Windows.Window.Show() in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 214 at
System.Windows.Window.ShowDialog() in
f:\dd\wpf\src\Framework\System\Windows\Window.cs:line 516 at
XXXXXX.Common.Controls.MultiButtonDialog.ShowOK(Object content, String
title) in
F:\git\XXXXXXX\Source\XXXXXX.Common\Dialogs\MultiButtonDialog.xaml.cs:line
55 at
XXXXXX.Wpf.VelocityErrorHandler.<>c__DisplayClass17_0.b__0()
in F:\git\XXXXXXX\Source\XXXXXX.Wpf\VelocityFatalErrorHandler.cs:line
216 at XXXXXX.Wpf.WpfDispatcher.Invoke(Action action) in
F:\git\XXXXXXX\Source\XXXXXX.Wpf\WpfDispatcher.cs:line 32 at
DFDS.Freight.Common.Core.DispatchContext.Invoke(Action action) in
F:\git\XXXXXXX\Source\DFDS.Freight.Common.Portable\Core\IDispatchContext.cs:line
30 at
XXXXXX.Wpf.VelocityErrorHandler.HandleFatalException(Exception
exception) in
F:\git\XXXXXXX\Source\XXXXXX.Wpf\VelocityFatalErrorHandler.cs:line 206
at XXXXXX.Wpf.VelocityErrorHandler.HandleAnyException(Exception
exception, Boolean isUnhandledTaskException) in
F:\git\XXXXXXX\Source\XXXXXX.Wpf\VelocityFatalErrorHandler.cs:line 113
at XXXXXX.Wpf.VelocityErrorHandler.HandleUnhandledException(Exception
exception, Boolean isUnhandledTaskException) in
F:\git\XXXXXXX\Source\XXXXXX.Wpf\VelocityFatalErrorHandler.cs:line 29
at
XXXXXX.Wpf.ApplicationInitializer.OnDispatcherUnhandledException(Object
sender, DispatcherUnhandledExceptionEventArgs e) in
F:\git\XXXXXXX\Source\XXXXXX.Wpf\ApplicationInitializer.cs:line 605
at System.Windows.Threading.Dispatcher.CatchException(Exception e)
at System.Windows.Threading.Dispatcher.CatchExceptionStatic(Object
source, Exception e) at
System.Windows.Threading.ExceptionWrapper.CatchException(Object
source, Exception e, Delegate catchHandler) at
System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,
Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl() at
System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object
state) at
MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object
obj) at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state) at
MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext
executionContext, ContextCallback callback, Object state) at
System.Windows.Threading.DispatcherOperation.Invoke() at
System.Windows.Threading.Dispatcher.ProcessQueue() at
System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32
msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at
MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam,
IntPtr lParam, Boolean& handled) at
MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Int32 numArgs) at
System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,
Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
I believe your solution is in fact as good as it gets. You cannot guarantee a stable state when you end up in the DispatcherUnhandledException event handler. For instance, if your exceptions is thrown from deep inside WPF you will likely not be able to bind properties. Your error message dialog would be blank.
Below you find a fix for that particular issue.
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
var errorMassage = ExceptionFormatter.FormatException(e.Exception)
try
{
// When the WPF framework throws, our error dialog will have problem binding data.
// In this case, we must revert to an oldschool message dialog in order to see
// the actual error message!
var isFrameworkError = ex.Source?.Equals("PresentationFramework") == true;
if (isFrameworkError)
{
MessageBox.Show(errorMassage, "Program error", MessageBoxButton.OK);
}
else
{
var window = new FatalErrorWindow(errorMassage );
window.ShowDialog();
}
}
catch (Exception ex)
{
MessageBox.Show(errorMassage, "Program error", MessageBoxButton.OK);
}
Application.Current.Shutdown(-1);
}
Related
Cannot find package babel-preset-react
I need help, there was an error while building the application. Cannot find package 'babel-preset-react' imported from Path\babel-virtual-resolve-base.js Installed in devDependencies: "#babel/cli": "^7.20.7", "#babel/core": "^7.20.7", "#babel/node": "^7.20.7", "#babel/plugin-transform-async-to-generator": "^7.20.7", "#babel/preset-env": "^7.20.2", "#babel/preset-react": "^7.18.6", "babel-eslint": "^10.1.0", "babel-jest": "^24.9.0", "babel-loader": "^8.2.2", "babel-preset-react-app": "^10.0.1", "babelify": "^10.0.0", In dependencies: "grunt-babel": "^8.0.0", "#babel/polyfill": "^7.12.1", .babelrc: { "presets": [ "#babel/preset-env", "#babel/preset-react" ] } Cannot find package 'babel-preset-react'. babel-preset-react is babel 6 version, I don't need it. I am using babel version 7. If I install babel-preset-react a new error occurs. Plugin/Preset files are not allowed to export objects, only functions. In Path\node_modules\babel-preset-react\lib\index.js Before that, I migrated from babel 6 to babel 7. Deleted node_modules and package-lock.json and npm install again
My release apk is crashing after splashcreen, how do I solve it?
my app crashes after the splash screen, for debug works perfectly. I think its something with a dependency but I don't really know and am out of ideas the flow is the next one, I run gradle installRelease and the app crashes instantly, but if I do a npm run android the app works smoothly without any problems { "name": "app", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint .", "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'", "bundle:ios": "react-native bundle --minify --dev false --assets-dest ./ios --entry-file index.js --platform ios --bundle-output ./ios/main.jsbundle", "postinstall": "npx jetifier && npm run bundle:ios" }, "dependencies": { "#amplitude/react-native": "^2.16.0", "#babel/plugin-transform-arrow-functions": "^7.18.6", "#babel/plugin-transform-shorthand-properties": "^7.18.6", "#babel/plugin-transform-template-literals": "^7.18.9", "#eva-design/eva": "^2.0.0", "#miblanchard/react-native-slider": "^1.5.0", "#react-native-async-storage/async-storage": "^1.17.10", "#react-native-community/art": "^1.2.0", "#react-native-community/checkbox": "^0.5.12", "#react-native-community/cli-platform-android": "^9.1.0", "#react-native-community/datetimepicker": "^6.3.0", "#react-native-community/masked-view": "^0.1.11", "#react-native-community/progress-bar-android": "^1.0.4", "#react-native-community/progress-view": "^1.3.2", "#react-native-community/push-notification-ios": "^1.10.1", "#react-native-firebase/analytics": "^12.7.5", "#react-native-firebase/app": "^12.7.5", "#react-native-firebase/dynamic-links": "^12.7.5", "#react-native-firebase/messaging": "^12.7.5", "#react-navigation/bottom-tabs": "^5.8.0", "#react-navigation/drawer": "^5.9.0", "#react-navigation/native": "^5.7.3", "#react-navigation/stack": "^5.9.0", "#reduxjs/toolkit": "^1.5.0", "#sentry/react-native": "^2.4.0", "#ui-kitten/components": "^5.0.0", "#victorzimnikov/react-native-wheel-picker-android": "^3.1.1", "appcenter": "^4.4.5", "appcenter-analytics": "^4.4.5", "appcenter-crashes": "^4.4.5", "axios": "^0.21.1", "hoist-non-react-statics": "^3.3.2", "i18next": "^21.6.0", "i18next-localstorage-cache": "^1.1.1", "install": "^0.13.0", "lodash": "^4.17.21", "metro": "^0.73.2", "moment": "^2.29.1", "npm": "^8.19.2", "nullthrows": "^1.1.1", "prop-types": "^15.7.2", "react": "^17.0.2", "react-hook-form": "^6.14.2", "react-i18next": "^11.15.1", "react-native": "^0.66.4", "react-native-anchor-carousel": "^4.0.1", "react-native-animated-dots-carousel": "^1.0.1", "react-native-app-intro-slider": "^4.0.4", "react-native-blob-util": "^0.16.2", "react-native-chart-kit": "^6.11.0", "react-native-charts-wrapper": "^0.5.9", "react-native-check-box": "^2.1.7", "react-native-dialog": "^8.0.1", "react-native-element-dropdown": "^1.8.4", "react-native-elements": "^3.2.0", "react-native-gesture-handler": "^2.6.2", "react-native-image-picker": "^3.1.2", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-languages": "^3.0.2", "react-native-modal-datetime-picker": "^9.1.0", "react-native-pager-view": "^5.4.1", "react-native-pdf": "^6.5.0", "react-native-progress": "^4.1.2", "react-native-progress-wheel": "^1.0.5", "react-native-push-notification": "^8.1.1", "react-native-reanimated": "^2.11.0", "react-native-responsive-screen": "^1.4.2", "react-native-safe-area-context": "^3.1.7", "react-native-screens": "^2.10.1", "react-native-searchable-dropdown": "^1.1.1", "react-native-shadow": "^1.2.2", "react-native-share": "^6.2.1", "react-native-simple-toast": "^1.1.3", "react-native-snap-carousel": "^3.9.1", "react-native-splash-screen": "^3.2.0", "react-native-svg": "^12.1.0", "react-native-swipe-list-view": "^3.2.6", "react-native-swipe-modal-up-down": "^1.0.9", "react-native-swipeable": "^0.6.0", "react-native-tab-view": "^3.1.1", "react-native-vector-icons": "^8.1.0", "react-native-version-number": "^0.3.6", "react-native-video": "^5.1.0-alpha8", "react-native-view-overflow": "^0.0.5", "react-native-webview": "^11.2.3", "react-native-wheel-pick": "^1.1.1", "react-native-wifi-reborn": "^4.7.0", "react-navigation": "^4.4.0", "react-navigation-stack": "^2.8.2", "react-redux": "^7.2.1", "redux": "^4.0.5", "redux-devtools-extension": "^2.13.8", "redux-thunk": "^2.3.0" }, "devDependencies": { "#babel/core": "^7.13.0", "#babel/runtime": "^7.19.4", "#react-native-community/eslint-config": "2.0.0", "#ui-kitten/metro-config": "^5.0.0", "babel-jest": "26.6.3", "eslint": "7.14.0", "eslint-config-airbnb": "^18.2.0", "eslint-config-standard": "^16.0.2", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-react": "^7.22.0", "eslint-plugin-react-hooks": "^4.1.0", "jest": "26.6.3", "metro-react-native-babel-preset": "^0.66.2", "prettier": "^2.2.1", "react-test-renderer": "^17.0.2" }, "jest": { "preset": "react-native" } } Here's the build.gradle apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://reactnative.dev/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/#sentry/react-native/sentry.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); android { packagingOptions { pickFirst '**/*.so' } compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.hobeen.android" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1661850434 versionName "0.2.7" multiDexEnabled true } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { storeFile file('keystore.jks') keyAlias 'upload' storePassword '8VNfjUzFPti5wF' keyPassword '8VNfjUzFPti5wF' } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled false proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation 'com.google.firebase:firebase-analytics:17.5.0' implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation 'com.facebook.fresco:fresco:2.6.0' // For animated GIF support implementation 'com.facebook.fresco:animated-gif:2.6.0' // For WebP support, including animated WebP implementation 'com.facebook.fresco:animated-webp:2.6.0' implementation 'com.facebook.fresco:webpsupport:2.6.0' implementation 'com.android.support:support-core-utils:24.2.1' implementation project(path: ":#react-native-firebase_dynamic-links") implementation project(':react-native-push-notification') implementation 'androidx.multidex:multidex:2.0.1' implementation platform('com.google.firebase:firebase-bom:26.2.0') implementation 'com.google.firebase:firebase-core:16.0.8' implementation 'com.google.firebase:firebase-messaging:17.6.0' implementation 'com.google.firebase:firebase-analytics' implementation 'com.android.support:design:28.+' implementation project(':react-native-wifi-reborn') implementation project(':react-native-screens') debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) and here's the logcat 10-18 11:52:56.136 18286 18286 E .hobeen.android: Not starting debugger since process cannot load the jdwp agent. 10-18 11:52:56.669 18286 18286 E unknown:ReactNative: Unable to launch logbox because react was unable to create the root view 10-18 11:52:57.031 18286 18341 E ReactNativeJS: TypeError: null is not an object (evaluating 'O.init') 10-18 11:52:57.045 18286 18341 E ReactNativeJS: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules 10-18 11:52:57.133 18286 18342 E AndroidRuntime: Process: com.hobeen.android, PID: 18286 10-18 11:52:57.133 18286 18342 E AndroidRuntime: com.facebook.react.common.JavascriptException: TypeError: null is not an object (evaluating 'O.init'), stack: 10-18 11:52:57.133 18286 18342 E AndroidRuntime: setOptions#1186:1182 10-18 11:52:57.133 18286 18342 E AndroidRuntime: <unknown>#1182:416 10-18 11:52:57.133 18286 18342 E AndroidRuntime: v#2:1473 10-18 11:52:57.133 18286 18342 E AndroidRuntime: <unknown>#1158:179 10-18 11:52:57.133 18286 18342 E AndroidRuntime: v#2:1473 10-18 11:52:57.133 18286 18342 E AndroidRuntime: <unknown>#609:273 10-18 11:52:57.133 18286 18342 E AndroidRuntime: v#2:1473 10-18 11:52:57.133 18286 18342 E AndroidRuntime: <unknown>#446:170 10-18 11:52:57.133 18286 18342 E AndroidRuntime: v#2:1473 10-18 11:52:57.133 18286 18342 E AndroidRuntime: <unknown>#406:176 10-18 11:52:57.133 18286 18342 E AndroidRuntime: v#2:1473 10-18 11:52:57.133 18286 18342 E AndroidRuntime: <unknown>#6:57 10-18 11:52:57.133 18286 18342 E AndroidRuntime: v#2:1473 10-18 11:52:57.133 18286 18342 E AndroidRuntime: d#2:875 10-18 11:52:57.133 18286 18342 E AndroidRuntime: global code#1720:3 10-18 11:52:57.133 18286 18342 E AndroidRuntime: 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:942) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) 10-18 11:52:57.133 18286 18342 E AndroidRuntime: at java.lang.Thread.run(Thread.java:1012) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: [AppErrors] null InputStream [CONTEXT service_id=254 ] 10-18 11:52:57.264 6892 18370 E DropBoxUtil: java.io.IOException: null InputStream 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at btqk.c(:com.google.android.gms#223616044#22.36.16 (190400-476895098):20) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at bton.apply(:com.google.android.gms#223616044#22.36.16 (190400-476895098):5) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at jrl.apply(:com.google.android.gms#223616044#22.36.16 (190400-476895098):0) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at jrz.apply(:com.google.android.gms#223616044#22.36.16 (190400-476895098):5) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at ckud.a(:com.google.android.gms#223616044#22.36.16 (190400-476895098):0) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at csyd.a(:com.google.android.gms#223616044#22.36.16 (190400-476895098):2) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at cyus.d(:com.google.android.gms#223616044#22.36.16 (190400-476895098):2) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at cyuu.run(:com.google.android.gms#223616044#22.36.16 (190400-476895098):9) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at cywe.execute(:com.google.android.gms#223616044#22.36.16 (190400-476895098):0) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at cyuq.q(:com.google.android.gms#223616044#22.36.16 (190400-476895098):1) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at cyuq.gl(:com.google.android.gms#223616044#22.36.16 (190400-476895098):4) 10-18 11:52:57.264 6892 18370 E DropBoxUtil: at cyuu.g(:com.google.android.gms#223616044#22.36.16 (190400-47689509
how do I fix error "Plugin/Preset files are not allowed to export objects"?
I have inherited a project that hasn't been touched in a few years. So my first step was to upgrade all of the dependencies. I got close to making it work but I am stuck on this one error: Error: Plugin/Preset files are not allowed to export objects, only functions I tried removing the rules from my webpack.config.js file. That wasn't much help. The project originally referenced 'es2015' and I updated that information to use 'es2016'. here's my package.json file { "name": "quant-engine", "version": "1.0.0", "description": "", "main": "index.js", "private": true, "scripts": { "start": "webpack-dev-server --progress --inline --port 8112", "build": "webpack", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "acorn": "^6.1.1", "babel-core": "^6.17.0", "babel-loader": "^8.0.5", "babel-preset-es2016": "^6.24.1", "babel-preset-react": "^6.5.0", "chai": "^4.2.0", "css-loader": "^2.1.1", "file-loader": "^3.0.1", "font-awesome": "^4.7.0", "moment": "^2.18.1", "prettier": "^1.17.0", "prop-types": "^15.7.2", "react": "^16.8.6", "react-bootstrap": "^1.0.0-beta.8", "react-currency-input": "^1.2.6", "react-date-picker": "^7.5.1", "react-dom": "^16.8.6", "react-fontawesome": "^1.6.1", "style-loader": "^0.23.1", "webpack": "^4.30.0", "webpack-dev-server": "^3.3.1" }, "devDependencies": { "#storybook/addon-actions": "^5.0.11", "#storybook/addon-links": "^5.0.11", "#storybook/addons": "^5.0.11", "#storybook/react": "^5.0.11", "webpack-cli": "^3.3.2" } } and here's my webpack.config.js file module.exports = { entry: './src/app.js', }, output: { path: __dirname, filename: 'bundle.js' }, module: { rules: [ { test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: [ 'es2016', 'react' ] } }, { test: /\.(png|jpg|gif)$/, loader: 'file-loader', exclude: /node_modules/, options: {} }, { test: /\.css$/, loader: 'style-loader!css-loader' } ] } }; I'm not familiar with babel. From what I can find, other people have posted this problem with no result (but their questions were never fully explained). I would like all of the project dependencies to be as current as possible. I do not want to downgrade any as much possible. Thnx edit: build output below. I do not have a .babelrc file. # npm start > quant-engine#1.0.0 start C:\src\projects\OptionAnalyzer\web > webpack-dev-server --progress --inline --port 8112 10% building 1/1 modules 0 activei 「wds」: Project is running at http://localhost:8112/ i 「wds」: webpack output is served from / × 「wdm」: Hash: c72e7c421021f65f90e2 Version: webpack 4.30.0 Time: 1030ms Built at: 2019-05-07 14:40:23 Asset Size Chunks Chunk Names bundle.js 349 KiB main [emitted] main Entrypoint main = bundle.js [0] multi (webpack)-dev-server/client?http://localhost:8112 ./src/app.js 40 bytes {main} [built] [./node_modules/ansi-html/index.js] 4.16 KiB {main} [built] [./node_modules/ansi-regex/index.js] 135 bytes {main} [built] [./node_modules/html-entities/index.js] 231 bytes {main} [built] [./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built] [./node_modules/node-libs-browser/node_modules/events/events.js] 13.3 KiB {main} [built] [./node_modules/querystring-es3/index.js] 127 bytes {main} [built] [./node_modules/strip-ansi/index.js] 161 bytes {main} [built] [./node_modules/url/url.js] 22.8 KiB {main} [built] [./node_modules/webpack-dev-server/client/index.js?http://localhost:8112] (webpack)-dev-server/client?http://localhost:8112 8.26 KiB {main} [built] [./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.59 KiB {main} [built] [./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built] [./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built] [./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 75 bytes {main} [built] [./src/app.js] 1.44 KiB {main} [built] [failed] [1 error] + 11 hidden modules ERROR in ./src/app.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Plugin/Preset files are not allowed to export objects, only functions. In C:\src\projects\OptionAnalyzer\web\node_modules\babel-preset-es2016\lib\index.js at createDescriptor (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-descriptors.js:178:11) at items.map (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-descriptors.js:109:50) at Array.map (<anonymous>) at createDescriptors (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-descriptors.js:109:29) at createPresetDescriptors (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-descriptors.js:101:10) at passPerPreset (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-descriptors.js:58:96) at cachedFunction (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\caching.js:33:19) at presets.presets (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-descriptors.js:29:84) at mergeChainOpts (C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-chain.js:320:26) at C:\src\projects\OptionAnalyzer\web\node_modules\#babel\core\lib\config\config-chain.js:283:7 i 「wdm」: Failed to compile.
Webapp using react-bootstrap loads ok the 1st time then: Uncaught TypeError: Super expression must either be null or a function
Hi I'm having a problem with the app I'm building. when i run webpack the app shows in screen and works perfect. But as soon as i make a change to any component and the servers loads the new data i got the console error: Uncaught TypeError: Super expression must either be null or a function, not undefined at Function.exports.default (bundle.js:401) at bundle.js:17796 at Object.<anonymous> (bundle.js:17873) at __webpack_require__ (bundle.js:20) at Object.<anonymous> (bundle.js:39700) at __webpack_require__ (bundle.js:20) at Object.<anonymous> (bundle.js:39400) at __webpack_require__ (bundle.js:20) at Object.defineProperty.value (bundle.js:39324) at __webpack_require__ (bundle.js:20) i have to remove and add react-bootstrap again to make it work. Happens on chrome and safari. Any help would be appreciated. Thanks. "dependencies": { "axios": "^0.16.2", "babel-cli": "6.24.1", "babel-core": "6.25.0", "babel-loader": "7.1.1", "babel-plugin-transform-class-properties": "6.24.1", "babel-preset-env": "1.5.2", "babel-preset-react": "6.24.1", "bootstrap": "3.3.7", "css-loader": "^0.28.7", "express": "^4.16.1", "extract-text-webpack-plugin": "^3.0.1", "file-loader": "^1.1.5", "live-server": "^1.2.0", "node-sass": "^4.5.3", "normalize.css": "^7.0.0", "react": "15.6.1", "react-bootstrap": "^0.31.3", "react-dom": "15.6.1", "sass-loader": "^6.0.6", "style-loader": "^0.18.2", "url-loader": "^0.6.2", "webpack": "3.1.0", "webpack-dev-server": "2.5.51" }
React Hot Loader - Ignored an update to unaccepted module
I am new to React and React Hot Loader. I have a Symfony 2.7 application and started to use webpack and react. In general everything works fine, but when I want to use Hot Reloading, I get the error: Ignored an update to unaccepted module ./app/Resources/js/app.js -> 0 [HMR] The following modules couldn't be hot updated: (They would need a full reload!) [HMR] - ./app/Resources/js/app.js Am I missing anything basic here. I am pretty new so it might be an easy answer to the problem. Thanks a lot Here is my basic code: package.json "dependencies": { "babel-core": "^6.25.0", "babel-loader": "^7.1.1", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", "babel-preset-stage-2": "^6.24.1", "react": "^15.6.1", "react-dom": "^15.6.1", "react-hot-loader": "^1.3.1", "webpack-dev-server": "^2.6.1" } app.js import React from 'react'; import ReactDOM from 'react-dom'; // import ReactHotLoader from 'react-hot-loader'; import Component from './component.js'; // const element = ; ReactDOM.render( <h1>Hello, world app </h1> , document.getElementById('app') ); webpack.config.js: var path = require('path'); var webpack = require('webpack'); var node_modules_dir = path.join(__dirname, 'node_modules'); var config = { entry: [ 'webpack-dev-server/client?http://127.0.0.1:3000', 'webpack/hot/only-dev-server', './app/Resources/js/app.js', ], output: { path: path.join(__dirname, 'web/dist'), filename: 'bundle.js', publicPath: 'http://127.0.0.1:3000/static/' }, plugins: [ new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), ], module: { loaders: [ { test: /\.js?$/, include: path.join(__dirname, 'app/Resources/js'), loader: "babel-loader", query: { presets:['react'] } } ] } }; module.exports = config; Output when starting the webpack dev server: node webpack.dev-server.js l Listening at 0.0.0.0:3000 Hash: 8c2dd25b4ae931392c17 Version: webpack 3.4.1 Time: 1977ms Asset Size Chunks Chunk Names bundle.js 1.09 MB 0 [emitted] [big] main [50] (webpack)/hot/log.js 1.04 kB {0} [built] [85] ./node_modules/react/react.js 56 bytes {0} [built] [118] multi webpack-dev-server/client?http://127.0.0.1:3000 webpack/hot/only-dev-server ./app/Resources/js/app.js 52 bytes {0} [built] [119] (webpack)-dev-server/client?http://127.0.0.1:3000 5.83 kB {0} [built] [120] ./node_modules/url/url.js 23.3 kB {0} [built] [126] ./node_modules/strip-ansi/index.js 161 bytes {0} [built] [128] ./node_modules/loglevel/lib/loglevel.js 6.74 kB {0} [built] [129] (webpack)-dev-server/client/socket.js 856 bytes {0} [built] [161] (webpack)-dev-server/client/overlay.js 3.6 kB {0} [built] [166] (webpack)/hot nonrecursive ^\.\/log$ 170 bytes {0} [built] [168] (webpack)/hot/only-dev-server.js 2.37 kB {0} [built] [169] (webpack)/hot/log-apply-result.js 1.31 kB {0} [built] [170] ./app/Resources/js/app.js 295 bytes {0} [built] [186] ./node_modules/react-dom/index.js 59 bytes {0} [built] [272] ./app/Resources/js/component.js 255 bytes {0} [built] + 258 hidden modules webpack: Compiled successfully.