Rg.plugins.popup: Exception in UWP opening popup window only in Release builds

Created on 3 May 2018  Â·  5Comments  Â·  Source: rotorgames/Rg.Plugins.Popup

Hi,
I get an exception whenever the app tries to open a popup in a UWP application, there is no error in Android and iOS. The error only occurs when the application is packaged and installed from that package, there is no error when the application in started from Visual Studio using Release or Debug builds. I tried to update to the last version of the library, but the error is still there.

Te exception details are pasted below:

  | Name | Value | Type
-- | -- | -- | --
â–¶ | $exception | {System.InvalidCastException: Specified cast is not valid. at Rg.Plugins.Popup.WinPhone.Impl.PopupPlatformWinPhone.d__11.MoveNext() in C:\projects\rg-plugins-popup\src\Rg.Plugins.Popup.WinShared\Impl\PopupPlatformWinPhone.cs:line 73 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 63 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 182 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 150 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 121 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 397 at Rg.Plugins.Popup.Services.PopupNavigationImpl.d__11.MoveNext() in C:\projects\rg-plugins-popup\src\Rg.Plugins.Popup\Services\PopupNavigationImpl.cs:line 111 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 63 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 182 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 150 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 121 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 397 at Rg.Plugins.Popup.Services.PopupNavigationImpl.d__7.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\Runtime\ExceptionServices\ExceptionDispatchInfo.cs:line 63 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 182 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 150 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 121 at System.Runtime.CompilerServices.TaskAwaiter.GetResult() in f:\dd\ndp\fxcoreCoreRT\src\System.Private.CoreLib\src\System\RuntimeCompilerServicesTaskAwaiter.cs:line 397 at KisenseMobile.Popups.ConfirmAlarmPopup.d__1.MoveNext() in D:\Work\Projectos\KisenseMobile03 Development\Source\KisenseMobile\KisenseMobile\PopupsConfirmAlarmPopup.xaml.cs:line 21} | System.InvalidCastException

Most helpful comment

All 5 comments

Same with me.

I'm using version 1.1.4.154-pre and this issue only occurs in UWP Release when Compile with .NET Native tool chain option is checked in UWP project build properties (which is required to package UWP apps to Windows Store).

Hello,
I've got the exactly the same issue on 1.1.4-154-pre. Plugin does not want to work in Native tool chain compliation mode.

EDIT - it was my fault, I haven't regsitered properly plugin in Init method.

Hi, there is a way to solve this problem?
How it is the way to registry properly the plugin in Init method?
Thanks

After digging for a while in the source code, I found a solution to this:

The plugin initialization in _App.xaml.cs_ (in the UWP project) must be changed from

Rg.Plugins.Popup.Popup.Init();
Xamarin.Forms.Forms.Init(e);

to

Rg.Plugins.Popup.Popup.Init();
Xamarin.Forms.Forms.Init(e, Popup.GetExtraAssemblies());
Was this page helpful?
0 / 5 - 0 ratings