Calling PushPopupAsync crashes UWP app in release mode
See original GitHub issueHi,
Rg.Plugins.Popup crashes in UWP in a app running in release mode (ARM build), tested on a Microsoft Lumia 650, Windows 10 mobile build against SDK 10580.
Unfortunately there’s not a lot in the insights stacktrace
System.NullReferenceExceptionArg_NullReferenceException
Raw
at Rg.Plugins.Popup.Services.PopupNavigation.PushAsync(Plugins.Popup.Pages.PopupPage page, Boolean animate)
at MarineOps.UWP!<BaseAddress>+0xefdfd9
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at SharedLibrary!<BaseAddress>+0x36fd1b
at SharedLibrary!<BaseAddress>+0x36fbe9
at SharedLibrary!<BaseAddress>+0x36fbb9
at SharedLibrary!<BaseAddress>+0x36fb97
at MarineOps.UWP!<BaseAddress>+0xefe35d
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at SharedLibrary!<BaseAddress>+0x401cbf
at SharedLibrary!<BaseAddress>+0x3ce85f
If you wrap it in a try catch so the app doesn’t crash but it won’t push a basic page.
<?xml version="1.0" encoding="utf-8"?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
CloseWhenBackgroundIsClicked="False"
BackgroundColor="#E6000000"
x:Class="MarineOps.Views.Popups.TestPopup">
<pages:PopupPage.Animation>
<animations:MoveAnimation
PositionIn="Center"
PositionOut="Center"
DurationIn="500"
DurationOut="350"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True" />
</pages:PopupPage.Animation>
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="34" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Header -->
<Grid Grid.Row="0" Margin="20,0,20,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="34" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" HorizontalOptions="FillAndExpand"
HorizontalTextAlignment="Center" BackgroundColor="Transparent"
VerticalTextAlignment="End"
Text="Cancel" />
<Label Grid.Column="0" Grid.ColumnSpan="3" HorizontalOptions="FillAndExpand"
HorizontalTextAlignment="Center"
VerticalTextAlignment="End"
Style="{StaticResource TopBarTextDataLabelStyle}"
Text="Create New" />
</Grid>
<AbsoluteLayout Grid.Row="1" VerticalOptions="FillAndExpand" Margin="0,30,0,0">
</AbsoluteLayout>
</Grid>
</pages:PopupPage>
private void Button_OnClicked(object sender, EventArgs e)
{
var page = new TestPopup();
try
{
Application.Current.MainPage.Navigation.PushPopupAsync(page);
}
catch (Exception ex)
{
_exceptionService.Error(ex.Message,ex);
}
}
`
It works fine in debug.
In app.xaml.s I added the init code, I included any renderers or controls the pluggin page might use but it makes no difference
`
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
Forms.Init(e);
FormsMaps.Init(BingKey);
Insights.HasPendingCrashReport += (sender, isStartupCrash) =>
{
if (isStartupCrash)
{
Insights.PurgePendingCrashReports().Wait();
}
};
#if DEBUG
Insights.Initialize(InsightsIdDebug);
#else
Insights.Initialize(InsightsIdRelease);
#endif
List<Assembly> assembliesToInclude = new List<Assembly>();
assembliesToInclude.Add(typeof(Rg.Plugins.Popup.Windows.Popup).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(Telerik.XamarinForms.DataControls.RadListView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(Telerik.XamarinForms.DataControlsRenderer.UWP.ListViewRenderer).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(Common.CustomRenderers.ImageButton).GetTypeInfo().Assembly);
Xamarin.Forms.Forms.Init(e, Rg.Plugins.Popup.Windows.Popup.GetExtraAssemblies(assembliesToInclude));
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
//ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
//ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
//ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
UWP - app crash in Release mode, missing dll?
After I unchecked the option "compile with the .net native tool chain" for the RELEASE Build, the app is working as expected.
Read more >UWP -Release Mode app crashes on start. Debug works ...
UWP app while running in release mode, crashes at the start of the APP. It works fine in debug and Android as well....
Read more >[UWP] Exception on start with Release mode
My UWP Xamarin Forms app crashes on startup ("Release-Mode") with the message: Unhandled exception at 0x7650A6E2 (KernelBase.dll) in ...
Read more >UWP/C# app crashes on startup when in "Release" from ...
The app runs fine in "Debug" mode in Visual Studio, however whenever trying to start it in "Release" mode the app throws a...
Read more >Xamarin UWP release mode crash but debug work
My steps with 16.8.3: Create a Mobile App (Xamarin.Forms) > Select Blank template with checking 'Windows UWP' option > Change configuration to Release...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I know this is closed, but it helped me figure out a solution to my similar problem and I’d like to add clarification to what I think @mackayn was explaining as a fix.
You simply need to make sure you’re adding all assemblies once. Only call Forms.Init() once. Lastly, call Rg.Plugins.Popup.Windows.Popup.Init() after you’ve called Forms.Init().
Here is a snippet you can put in App.xaml.cs.OnLaunched in your UWP project:
@rotorgames
I can’t believe I did this, I had already called init without the arguments. Literally hitting my head of the desk.
` rootFrame.NavigationFailed += OnNavigationFailed;
`
Anyway, all working now. Thanks for your help.
This library is awesome btw, great work.