Mvvmcross: UWP Release Builds are crashing at runtime

Created on 2 May 2018  路  4Comments  路  Source: MvvmCross/MvvmCross

Release builds on UWP are crashing at runtime at startup with a 'System.PlatformNotSupportedException' in System.Private.CoreLib.dll` exception. A repository to reproduce is here https://github.com/ueman/mvvmcross6crash

The UWP Playground should yield the same behaviour as the provided repository.

Upon further investigation this seems to be a problem with the build option Compile with .NET Native tool chain. If the option is turned off it works as expected, however you can't deploy to the Windows App Store. So this is still a problem.

Steps to reproduce :scroll:

  1. Create new project with MvvmCross 6. The Core project is a .Net Standard 2 Class Library and the UWP project is a Universal Windows Project. MvvmCross is included as NuGet.

  2. Compile release build.

  3. Run release build.

Expected behavior :thinking:

The application should not crash.

Actual behavior :bug:

The application crashes with a Exception thrown: 'System.PlatformNotSupportedException' in System.Private.CoreLib.dll Exception.

Configuration :wrench:

Version: 6.0.0 and 6.0.1

Platform:

  • [ ] :iphone: iOS
  • [ ] :robot: Android
  • [ ] :checkered_flag: WPF
  • [x] :earth_americas: UWP
  • [ ] :apple: MacOS
  • [ ] :tv: tvOS
  • [ ] :monkey: Xamarin.Forms
uwp

Most helpful comment

Good find - frustrating that it works in debug but not release (thanks for the great simple example)
Workaround - use a custom setup class that overrides getpluginassembly
public class CustomSetup: MvxWindowsSetup
{
public override IEnumerable GetPluginAssemblies()
{
return new[] { typeof(MvxPluginAttribute).Assembly };
}
}

All 4 comments

Good find - frustrating that it works in debug but not release (thanks for the great simple example)
Workaround - use a custom setup class that overrides getpluginassembly
public class CustomSetup: MvxWindowsSetup
{
public override IEnumerable GetPluginAssemblies()
{
return new[] { typeof(MvxPluginAttribute).Assembly };
}
}

Thanks for the response. That does indeed fix it.

After some research i think the exception comes from the code in this method https://github.com/MvvmCross/MvvmCross/blob/082ce799a17f31839b7c1221aacc4737942bc58e/MvvmCross/Core/MvxSetup.cs#L270 and has something to do with reflection.

@ueman as per my workaround, the issue is that GetPluginAssembly (which is called by InitializePluginFramework) is calling a method that isn't supported on UWP

Closing because the issue was fixed.

Was this page helpful?
0 / 5 - 0 ratings