Xamarin表单:在UWP中使用displayactionsheet时获取异常(Android部分工作正常)

问题描述 投票:0回答:1

当使用displayactionsheet和app停止在UWP中工作时,我得到以下异常,android部分工作正常。

The thread 0x5464 has exited with code 0 (0x0).
The thread 0xac4 has exited with code 0 (0x0).
The program '[12688] Business_App.UWP.exe' has exited with code -1 (0xffffffff).
Exception thrown: 'System.Exception' in Business_App.UWP.McgInterop.dll
Exception thrown: 'System.Exception' in System.Private.CoreLib.dll
Unhandled exception at 0x0715DC3C (Windows.UI.Xaml.dll) in Business_App.UWP.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x11665010, 0x00000004).

以下是我的代码:

string action = await DisplayActionSheet(null, "Cancel", null, "View History", "Add Customers");
if (action == "View History")
 {
    //Do some stuff
 }
 else if (action == "Add Customers")
 {
    //Do some stuff
 }

我在DisplayActionSheet行添加了断点和app break并重定向到App.g.i.cs.截图添加如下。 enter image description here

对我来说这是一个新问题,任何人都可以建议一个解决方案。

提前致谢。

exception xamarin.forms
1个回答
0
投票

终于找到了问题。

问题出在xaml文件中,我错误地关闭了stacklayout。

    <StackLayout
                x:Name="selectedlocationLayout"
                IsVisible="False"
                  Orientation="Horizontal">

        // UI attributes    

        <StackLayout.GestureRecognizers>
                    <TapGestureRecognizer
                    Tapped="SelectedLocationGesture"
                    NumberOfTapsRequired="1">
                    </TapGestureRecognizer>
                </StackLayout.GestureRecognizers>
            </StackLayout>

我在stacklayout GestureRecognizers之前添加了StackLayout的close标签。

请参阅App.g.i.cs的第50行,告诉xaml在未处理的异常中生成中断。我是否再次验证xaml并选择问题。

© www.soinside.com 2019 - 2024. All rights reserved.