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

时间:2019-03-05 09:21:24

标签: c# .net xamarin.forms uwp

在发布模式下运行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).

这发生在 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);
            }

在此行内:

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

这仅在我以发布模式运行应用程序时发生,如果我在 Debug 中运行,则不会发生错误。

2 个答案:

答案 0 :(得分:0)

在发布模式下,您已执行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);

因此,您每使用一行assembliesToInclude.Add(typeof (ClassInOtherAssembly).GetTypeInfo().Assembly);

就添加第3方类

答案 1 :(得分:0)

我通过在UWP项目中取消选中“使用.NET本机工具链进行编译”来修复此问题。但是我不确定这是否只是临时解决方法

相关问题