【问题标题】:UWP App crashes on startupUWP 应用程序在启动时崩溃
【发布时间】:2017-09-18 07:49:59
【问题描述】:

我们开发了一个 UWP 应用程序,它可以在大多数设备上正常运行。但是,客户使用 Windows 10 1511 管理设备,应用程序在启动后立即崩溃。我们无法将 VS 调试器附加到它,因此我们使用 windbg 来启动和中断应用程序。从我所见,下面windbg 的输出是应用程序崩溃的地方。

应用启动事件被精简到几乎为空,因此启动后没有代码运行,但应用仍然崩溃。

知道如何进一步跟踪吗?

谢谢

ModLoad: 00007ffe`ec020000 00007ffe`ec27f000   C:\Windows\SYSTEM32\dwrite.dll
ModLoad: 00007ffe`cfef0000 00007ffe`d0075000   C:\Windows\System32\Windows.Globalization.dll
(241c.2278): Windows Runtime Originate Error - code 40080201 (first chance)
(241c.2278): Windows Runtime Originate Error - code 40080201 (first chance)
windows\dxaml\xcp\components\deferral\customwriterruntimeobjectcreator.cpp(222)\Windows.UI.Xaml.dll!00007FFED0E99DA7: (caller: 00007FFED0B7A503) Exception(1) tid(2278) 80004005 Unspecified error
(241c.2278): C++ EH exception - code e06d7363 (first chance)
(241c.2278): C++ EH exception - code e06d7363 (first chance)
windows\dxaml\xcp\core\core\elements\style.cpp(582)\Windows.UI.Xaml.dll!00007FFED0D851D9: (caller: 00007FFED0BFB365) ReturnHr(1) tid(2278) 80004005 Unspecified error
windows\dxaml\xcp\components\deferral\customwriterruntimeobjectcreator.cpp(113)\Windows.UI.Xaml.dll!00007FFED0DEEE15: (caller: 00007FFED0B0B954) Exception(2) tid(2278) 80004005 Unspecified error
(241c.2278): C++ EH exception - code e06d7363 (first chance)
(241c.2278): C++ EH exception - code e06d7363 (first chance)
windows\dxaml\xcp\components\resources\resourcedictionary2.cpp(48)\Windows.UI.Xaml.dll!00007FFED0D67F6D: (caller: 00007FFED0B67966) ReturnHr(2) tid(2278) 80004005 Unspecified error
(241c.2278): Windows Runtime Originate Error - code 40080201 (first chance)
(241c.2278): CLR exception - code e0434352 (first chance)
(241c.2278): Windows Runtime Originate Error - code 40080201 (first chance)
ModLoad: 00007ffe`ea590000 00007ffe`ea5f8000   C:\Windows\System32\mscoree.dll
ModLoad: 00007ffe`e9630000 00007ffe`e96cd000   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
ModLoad: 00007ffe`ea590000 00007ffe`ea5f8000   C:\Windows\System32\mscoree.dll
ModLoad: 00007ffe`e9630000 00007ffe`e96cd000   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
(241c.2278): CLR exception - code e0434352 (first chance)
(241c.2278): CLR exception - code e0434352 (first chance)
(241c.2278): Windows Runtime Originate Error - code 40080201 (first chance)
(241c.2278): Windows Runtime Originate Error - code 40080201 (first chance)
ntdll!NtWaitForMultipleObjects+0x14:
00007ffe`f7b25c24 c3              ret
0:000> g
       ^ No runnable debuggees error in 'g'

更新 1

我做了进一步的测试,结果发现,当我删除包含一些 xaml 样式的共享字典的引用时,该应用程序可以正常工作,即使在 1511 上也是如此。我检查了所有引用并玩了一遍,但没有一个能成功它适用于 1511。我真的看不出 1607 中引入了什么 1511 还没有。同样,在 1607 和 1703 版本上一切正常。这是代码:

项目 1(主 UWP 应用)

App.xaml

<Application
x:Class="XXXXXXXXXXXXXXXXXXXXXX"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="XXXXXXXXXXXXXXXXXXXX"
RequestedTheme="Light">
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ms-appx:///SDX.Library/SdxStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

项目 2(空的 UWP 项目,只有样式和资产)SDX.Library.dll

Styles.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="SdxColors.xaml" />
    <ResourceDictionary Source="SdxControls.xaml" />
</ResourceDictionary.MergedDictionaries>

SdxColors.xaml

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<SolidColorBrush x:Key="DarkGrey" Color="#FF333333"/>
<SolidColorBrush x:Key="DarkGrey40p" Color="#FFADADAD"/>
<SolidColorBrush x:Key="DarkGrey80p" Color="#5C5C5C"/>
<SolidColorBrush x:Key="InteractionBlue" Color="#FF1781E3"/>
<SolidColorBrush x:Key="BlueRollover" Color="#FF0851DA"/>

<SolidColorBrush x:Key="Successfull" Color="#FF25B252" />
<SolidColorBrush x:Key="Warning" Color="#FFFF8B2E" />
<SolidColorBrush x:Key="Peppermint" Color="#FF0EABA9" />

SdxControls.xaml

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

<FontFamily x:Key="TheSansB4SemiLight">Assets/Fonts/TheSansB_400_.ttf#TheSans B4 SemiLight</FontFamily>
<FontFamily x:Key="TheSansB5Plain">Assets/Fonts/TheSansB_500_.ttf#TheSans B5 Plain</FontFamily>

<Style TargetType="Button">
    <Setter Property="Background" Value="{ThemeResource InteractionBlue}"/>
    <Setter Property="Foreground" Value="{ThemeResource ButtonForeground}"/>
    <Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderBrush}"/>
    <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/>
    <Setter Property="Padding" Value="32,8,32,8"/>
    <Setter Property="HorizontalAlignment" Value="Left"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="FontFamily" Value="{StaticResource TheSansB4SemiLight}"/>
    <Setter Property="FontWeight" Value="Normal"/>
    <Setter Property="FontSize" Value="18"/>
    <Setter Property="UseSystemFocusVisuals" Value="False"/>
    <Setter Property="FocusVisualMargin" Value="-3"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Grid x:Name="RootGrid" Background="{TemplateBinding Background}" CornerRadius="5" RenderTransformOrigin="0.5,0.5">
                    <Grid.RenderTransform>
                        <CompositeTransform/>
                    </Grid.RenderTransform>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal">
                                <VisualState.Setters>
                                    <Setter Target="RootGrid.(Panel.Background)" Value="{StaticResource InteractionBlue}"/>
                                </VisualState.Setters>
                                <Storyboard>
                                    <PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="PointerOver">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BlueRollover}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Pressed">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BlueRollover}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <PointerDownThemeAnimation Storyboard.TargetName="RootGrid"/>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Disabled">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid">
                                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource InteractionBlue}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimation Duration="0" To="0.4" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="RootGrid" d:IsOptimized="True"/>
                                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ContentPresenter" d:IsOptimized="True"/>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Foreground="White"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

【问题讨论】:

  • 应用程序不会因第一次机会异常而崩溃,因此您发布的日志可能相关也可能不相关。您必须注意第二次机会异常(那些是尚未被捕获且即将关闭进程的异常)。
  • 想知道崩溃的手机是否因为手机缺少您在应用程序中使用的功能而崩溃。
  • 应用在 Windows 10 桌面版上运行。我在调试器中按了“g”,但似乎到此为止。 windbg 中正确的命令集是什么?
  • 它是否在 1511 的机器上持续崩溃(但在 1607 上工作)?如果是,我会猜测您在代码(或 XAML 中)中使用了 1607 年引入但 1511 年不存在的类型。
  • @StefanWickMSFT 感谢 Stefan。我进一步调查并用一些代码更新了我的帖子。有什么想法吗?

标签: c# uwp win-universal-app windbg


【解决方案1】:

听起来您正在使用更新版本的 SDK 重新模板化 Button 控件。它可能引用了 10586 上不存在的资源。您需要使用旧版本重做重新模板化。最简单的方法是从 generic.xaml 复制/粘贴样式,您可以在此处找到:

C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP

如果您安装了 10586 SDK,您应该会看到一个“10.0.10586.0”文件夹。在那里,您会找到 \Generic\generic.xaml。打开该文件,找到基本的 Button 样式。将整个样式复制/粘贴到您的 SDXControls.xaml 中,替换现在的样式。

这是模板的向后兼容版本。如果一切顺利,您的应用应该不会再在 10586 上崩溃。

您可以从那里调整模板以满足您的设计需求。

提示:您还可以将“x:Key”属性添加到您的样式中,然后在您的按钮上明确引用样式作为静态资源。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-02
    • 1970-01-01
    相关资源
    最近更新 更多