Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

UWP release build causes runtime errors

sachinkanadiasachinkanadia GBMember ✭✭
edited June 2016 in Xamarin.Forms

When I configure my UWP app to build on release it compiles fine, but during runtime I receive lots of exceptions:

Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.PlatformNotSupportedException' in System.Private.Interop.dll
Exception thrown: 'System.AggregateException' in System.Private.Threading.dll

Why is this happening? And what should I do to resolve this problem?


  • huangjinshehuangjinshe USMember ✭✭✭

    Any new result?

  • sachinkanadiasachinkanadia GBMember ✭✭

    well I haven't solved the problem, but it seems that running on release build without debugging works fine even though those errors are apparent when debugging the app. I've submitted to the store and they've reported that my app silently crashes - now it could be because of this or something completely different I don't know. But will delve into further and post my findings.

  • JohandePunderJohandePunder NLBeta, University

    I have the same problem in our project. A lot of these messages when running in Release mode with 'Compile with .NET Native tool chain' turned on.
    Exception thrown: 'System.PlatformNotSupportedException' in System.Private.Interop.dll
    Opening a new page is very slow because of this. I can't release our app to the Windows Store now.
    When turning 'Compile with .NET Native tool chain' off, these errors disappear, but you can't build a Windows Store app package then.

  • BradChase.2654BradChase.2654 USMember ✭✭✭

    @sachinkanadia @JohandePunder Have you guys figured out how to solve that problem yet? We dont need to go into the store as of this moment, but it will be needed and the app is littered with:

    Exception thrown: 'System.PlatformNotSupportedException' in System.Private.Reflection.Execution.dll


  • JohandePunderJohandePunder NLBeta, University

    @BradChase.2654 No, I've tried to put this (for my project) in my App.xaml.cs in UWP project, but I still get a lot of these 'System.PlatformNotSupportedException' exceptions.

    var renderAssemblies = new[]
    Xamarin.Forms.Forms.Init(e, renderAssemblies);

    Also have a look here:

    I didn't get this to work.

    Also see the discussion here:

    Seems there is no solution yet. Hopefully someone at Xamarin can help here.

  • flchauxflchaux FRMember ✭✭


    Did someone find a solution or any clue to solve this ?

  • BobbyTablesBobbyTables GBMember ✭✭

    Also waiting for a solution.

  • MartinSmisekMartinSmisek USMember ✭✭

    The same issue, any solution ?

  • NicholasBauerNicholasBauer USMember ✭✭

    Getting these as well.

    PlatformNotSupportedException when it tries to load one of my custom control XAML files.

    FileNotFoundException inside AggregateException in:
    [Managed to Native Transition]
    System.Private.Threading.dll!System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions) Line 1994 C#
    System.Private.WinRTInterop.CoreLib.dll!Internal.WinRT.Interop.WinRTCallbacks.ReadFileIntoStream(string name) Line 371 C#
    System.Private.Reflection.Execution.dll!Internal.Reflection.Execution.ExecutionEnvironmentImplementation.ReadFileFromAppPackage(string name) Line 138 C#
    System.Private.Reflection.Execution.dll!Internal.Reflection.Execution.ExecutionEnvironmentImplementation.GetManifestResourceStream(System.Reflection.Assembly assembly, string name) Line 49 C#
    System.Private.Reflection.Core.dll!System.Reflection.Runtime.Assemblies.RuntimeAssembly.GetManifestResourceStream(string name) Line 176 C#
    Xamarin.Forms.Xaml.dll!Xamarin.Forms.Xaml.XamlLoader.ReadResourceAsXaml(System.Type type, System.Reflection.Assembly assembly, string likelyTargetName, bool validate) C#
    Xamarin.Forms.Xaml.dll!Xamarin.Forms.Xaml.XamlLoader.GetXamlForType(System.Type type) C#
    Xamarin.Forms.Xaml.dll!Xamarin.Forms.Xaml.XamlLoader.Load(object view, System.Type callingType) C#
    MyApp.dll!MyApp.Controls.MyGrid.MyGrid() C#

    It's only this one type, and not any of my other custom XAML types.

  • NicholasBauerNicholasBauer USMember ✭✭

    Ahhh... it's because the type didn't have the attribute "[XamlCompilation(XamlCompilationOptions.Compile)]" on it. Don't know why, but no more exceptions.

  • huhh... but that's not an option when loading the XAML from file during runtime :neutral:

  • rarenivarrarenivar USMember ✭✭

    This is still an issue, even after following the troubleshooting here by adding the assemblies and dependecy services referenced by the app.

  • DevologyDevology GBMember ✭✭✭

    In case it helps anyone, for me to get UWP working in debug and release mode I needed to

    1) Change the Ninject Nuget - 'The dependency injection' library that wires up all the services breaks on UWP, but the equivalent called 'Ninject.Portable' happily works on UWP and I've re-tested on iOS and Android.

    2) Image Resources - UWP doesn't like loading the images embedded in the app, so a small fix required and now that works too.

    Specifically any lines where you call ImageSource.FromResource(source) needs to change to

    var imageSource = ImageSource.FromResource(Source, Assembly.GetExecutingAssembly());
Sign In or Register to comment.