简体   繁体   English

发行模式下的Xamarin.UWP运行时错误

[英]Xamarin.UWP Runtime error in Release mode

I get an error when running my Xamarin.Forms.UWP app in Release Mode. 在发布模式下运行Xamarin.Forms.UWP应用时出现错误。

onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!00007FFD5E991DAA: (caller: 00007FFD5E990205) ReturnHr(1) tid(6adc) 80040154 Klasse nicht registriert
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!00007FFD5E991DAA: (caller: 00007FFD5E990205) ReturnHr(2) tid(2ac4) 80040154 Klasse nicht registriert
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!00007FFD5E991DAA: (caller: 00007FFD5E990205) ReturnHr(3) tid(39ec) 80040154 Klasse nicht registriert
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!00007FFD5E991DAA: (caller: 00007FFD5E990205) ReturnHr(4) tid(27a4) 80040154 Klasse nicht registriert
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll
Exception thrown: 'System.PlatformNotSupportedException' in System.Private.CoreLib.dll
Exception thrown: 'System.PlatformNotSupportedException' in System.Private.Interop.dll
Unhandled exception at 0x00007FFD43DB83B9 (Windows.UI.Xaml.dll) in Lama.Forms.UWP.exe: 0xC000027B: Anwendungsinterne Ausnahme (parameters: 0x000001FF87EB6FA0, 0x0000000000000002).

This happens inside the automatic generated code-section inside App.xaml.cs 这发生在App.xaml.cs内的自动生成的代码段内

protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            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;

                Xamarin.Forms.Forms.Init(e);

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // 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);
            }

Inside this line: 在此行内:

rootFrame.Navigate(typeof(MainPage), e.Arguments);

This only happens if I run the app in Release mode, if I do in Debug , there is no error happening. 仅当我在发布模式下运行应用程序时才会发生这种情况,如果我在Debug中运行 ,则不会发生任何错误。

In Release Mode, you have do load Assemblies on your own : 在发布模式下,您可以自己加载程序集

// You'll need to add using System.Reflection;

List<Assembly> assembliesToInclude = new List<Assembly>();

// Now, add in all the assemblies your app uses
assembliesToInclude.Add(typeof (ClassInOtherAssembly).GetTypeInfo().Assembly);

// Also do this for all your other 3rd party libraries
Xamarin.Forms.Forms.Init(e, assembliesToInclude);
// replaces Xamarin.Forms.Forms.Init(e);

So add every 3rd party class you use 1 line assembliesToInclude.Add(typeof (ClassInOtherAssembly).GetTypeInfo().Assembly); 因此,添加每个使用第3行的类,使用1行assembliesToInclude.Add(typeof (ClassInOtherAssembly).GetTypeInfo().Assembly);

I fixed it by unchecking "Compile with .NET Native tool chain" inside my UWP project. 我通过在UWP项目中取消选中“使用.NET Native工具链进行编译”来解决此问题。 But I am not sure if this is only a temporary fix 但是我不确定这是否只是临时解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM