Xamarin形式:在UWP中使用displayactionsheet时获取异常(Android部件工作正常)

时间:2018-09-17 06:43:16

标签: exception xamarin.forms

使用displayactionsheet时出现以下异常,并且应用程序停止在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.g.i.cs。屏幕截图如下。 enter image description here

对我来说这是一个新问题,任何人请提出解决方案。

谢谢。

1 个答案:

答案 0 :(得分: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并选择了问题。