启动画面后,Windows 10 UWP应用程序立即关闭/崩溃

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

我习惯使用.net框架编写windows程序。但是,由于我需要在我的程序中实现蓝牙低能量连接,因此我熟悉UWP并设计了一个UWP应用程序来连接到GATT服务器并阅读特性。该应用程序或多或少基于this Windows BluetoothLE example,但我删除了未使用的功能,并摆脱了框架概念。我可以使用我的笔记本电脑上的Visual Studio Community 2017(15.9.9)编译和运行此应用程序(Windows 10.0.17763)。但是,在创建软件包并将其安装到那里之后(在开启安装开发人员模式之前),我无法在Windows 10.0.17134的其他笔记本电脑上运行此应用程序。该应用程序在开始菜单中可用,可以启动,但我只看到启动画面几秒钟,然后应用程序消失。在Interstingly,我成功打包,安装和运行原始的BluetoothLE示例以及一个非常简单的应用程序,只有一个按钮,基于10.0.17134笔记本电脑上的UWP模板。因此,系统的设置和打包过程似乎是正确的,以将应用程序侧载到另一台笔记本电脑。

根据我的研究到目前为止,问题可能是由MainPage.xaml中的XAML属性引起的,这些属性无法由较低的Windows版本处理。 MainPage.xaml是:

<Page
x:Class="Bluetooth_UWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Bluetooth_UWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid RequestedTheme="Default"  ScrollViewer.HorizontalScrollBarVisibility="Auto" Height="535" BorderBrush="DarkBlue" BorderThickness="3" Width="1050" VerticalAlignment="Stretch"  >
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0*"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition Height="80" />
        <RowDefinition Height="300" />
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Button Grid.Row="0" x:Name="button_start" Content="Bluetooth Start" HorizontalAlignment="Left" Margin="13,0,0,0" VerticalAlignment="Center" Click="Button_Click" Height="33" Width="114" Grid.ColumnSpan="2"/>
    <Button Grid.Row="2" x:Name="button_send" Content="Send Hex" HorizontalAlignment="Left" Margin="826,92.6,0,0" VerticalAlignment="Top" Height="47" Width="211" Click="Button_send_Click" Grid.ColumnSpan="2"/>
    <TextBox Grid.Row="2" x:Name="Connection_Status" HorizontalAlignment="Left" Margin="13,35.6,0,0" Text="" VerticalAlignment="Top" Height="104" Width="500" AcceptsReturn="True" InputScope="Text" IsReadOnly="True" FontFamily="Lucida Console" TextChanged="Connection_Status_TextChanged" Grid.ColumnSpan="2"/>
    <TextBox Grid.Row="2" x:Name="Bluetooth_Rec_Text" HorizontalAlignment="Left" Margin="518,35.6,0,0" Text="" VerticalAlignment="Top" Height="105" Width="303" AcceptsReturn="True" InputScope="Text" IsReadOnly="True" FontFamily="Lucida Console" TextChanged="Bluetooth_Rec_Text_TextChanged" Grid.ColumnSpan="2"/>
    <TextBox Grid.Row="2" x:Name="Bluetooth_Send_Text" HorizontalAlignment="Left" Margin="826,35.6,0,0" Text=""  VerticalAlignment="Top" Height="52" Width="211" FontFamily="Lucida Console" TextChanged="Bluetooth_Send_Text_TextChanged" Grid.ColumnSpan="2"/>
    <TextBlock Grid.Row="2" x:Name="Text_Meldungen" HorizontalAlignment="Left" Margin="13,13.6,0,0" Text="Bluetooth-Meldungen:" TextWrapping="Wrap" VerticalAlignment="Top" Height="19" Width="140" Grid.ColumnSpan="2"/>
    <TextBlock Grid.Row="2" x:Name="Text_Empfangsdaten" HorizontalAlignment="Left" Margin="518,13.6,0,0" Text="Empfangsdaten:" TextWrapping="Wrap" VerticalAlignment="Top" Height="19" Width="99" Grid.ColumnSpan="2"/>
    <Image Grid.Row="1" x:Name="Sensorvisualisierung" HorizontalAlignment="Left" Height="64" Margin="13,35.6,0,0" VerticalAlignment="Top" Width="952" Stretch="None" Grid.ColumnSpan="2"/>
    <TextBlock Grid.Row="1" HorizontalAlignment="Left" Margin="13,13.6,0,0" Text="Biegung:" TextWrapping="Wrap" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
    <Image Grid.Row="1" x:Name="Sensorvisualisierung_Torsion"  HorizontalAlignment="Left" Height="25" Margin="13,135.6,0,0" VerticalAlignment="Top" Width="952" Stretch="None" Grid.ColumnSpan="2"/>
    <TextBlock Grid.Row="1" HorizontalAlignment="Left" Margin="13,113.6,0,0" Text="Torsion" TextWrapping="Wrap" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
    <CheckBox Grid.Row="1" x:Name="checkBox_Zahlen"  Content="Zahlen einblenden" HorizontalAlignment="Left" Margin="13,183.6,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
    <TextBlock Grid.Row="1" x:Name="Text_Werte_Biegung_1" HorizontalAlignment="Left" Margin="11,46.6,0,0" Text="XX" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="11" FontFamily="Lucida Console" Width="979" Grid.ColumnSpan="2"/>
    <TextBlock Grid.Row="1" x:Name="Text_Werte_Biegung_2" HorizontalAlignment="Left" Margin="11,78.6,0,0" Text="XX" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="11" FontFamily="Lucida Console" Width="979" Grid.ColumnSpan="2"/>
    <TextBlock Grid.Row="1" x:Name="Text_Werte_Torsion" HorizontalAlignment="Left" Margin="11,145.6,0,0" Text="XX" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="11" FontFamily="Lucida Console" Width="979" Grid.ColumnSpan="2"/>
    <ComboBox Grid.Row="0" x:Name="Sensorlaenge_List" ItemsSource="{x:Bind Sensorlaenge_Wahl}" DisplayMemberPath="" HorizontalAlignment="Left" Margin="150,0,0,0" Width="190" VerticalAlignment="Center" Visibility="Visible" SelectedIndex="0" SelectionChanged="Sensorlaenge_List_SelectionChanged" Grid.ColumnSpan="2"/>
    <RadioButton Grid.Row="0" x:Name="RadioButton_BT" Content="Bluetooth" HorizontalAlignment="Left" Margin="480,-32,0,0" VerticalAlignment="Center" Grid.ColumnSpan="2" Checked="RadioButton_Uebertragung_Checked" GroupName="RadioButton_Uebertragung" IsChecked="True"/>
    <RadioButton Grid.Row="0" x:Name="RadioButton_USB" Content="USB" HorizontalAlignment="Left" Margin="480,32,0,0" VerticalAlignment="Center" Grid.ColumnSpan="2" Checked="RadioButton_Uebertragung_Checked" GroupName="RadioButton_Uebertragung"/>
    <AppBarToggleButton Grid.Row="0" x:Name="Button_Messung_Start" HorizontalAlignment="Left" Label="Starte Messung" Margin="690,0,0,0" VerticalAlignment="Center" Width="130" Icon="Play"  Click="Button_Messung_Start_Click" Grid.ColumnSpan="2"/>
    <Button Grid.Row="0" x:Name="Button_Reset" Content="Kalibrierung" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="360,0,0,0" VerticalAlignment="Center" Width="100" Click="Button_Reset_Click"/>
    <TextBox Grid.Row="0" x:Name="Messfrequenz" HorizontalAlignment="Left" Margin="600,40,0,0" Text="10" VerticalAlignment="Center" Grid.ColumnSpan="2" InputScope="Number" Width="64" TextChanged="Messfrequenz_TextChanged"/>
    <TextBlock Grid.ColumnSpan="2" x:Name="Text_Messfrequenz" HorizontalAlignment="Left" Margin="600,-30,0,0" Text="Messfrequenz:" TextWrapping="Wrap" VerticalAlignment="Center"/>
    <TextBlock Grid.ColumnSpan="2" x:Name="Text_Hz" HorizontalAlignment="Left" Margin="670,40,0,0" Text="Hz" TextWrapping="Wrap" VerticalAlignment="Center"/>
    <TextBlock Grid.ColumnSpan="2" x:Name="TexT_Bewegungsart" HorizontalAlignment="Left" Margin="10,235,0,0" Grid.Row="1" Text="Bewegung" TextWrapping="Wrap" VerticalAlignment="Top"/>

</Grid>

是否有错误的陈述或遗漏的东西?

此外,我在Package.appxmanifest中尝试了不同的更改,比如将资产 - 徽标的数量减少到最小,这没有帮助。请注意,包括蓝牙功能(我也尝试了bluetooth.genericAttributeProfile,它不起作用,现在已注释掉)。 (串口部分是另一个与此问题无关的测试。)

    <?xml version="1.0" encoding="utf-8"?>
   <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
  <Identity Name="c6fb0f30-b3d7-4391-bf30-ee483792dc9c" Publisher="CN=Company" Version="0.1.40.0" />
  <mp:PhoneIdentity PhoneProductId="c6fb0f30-b3d7-4391-bf30-ee483792dc9c" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
  <Properties>
    <DisplayName>Bluetooth UWP Testsoftware</DisplayName>
    <PublisherDisplayName>Company</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.15063.0" MaxVersionTested="10.0.17763.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Bluetooth_UWP.App">
      <uap:VisualElements DisplayName="Bluetooth UWP App" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Bluetooth UWP Software" BackgroundColor="transparent">
        <uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#ffffff" />
        <uap:InitialRotationPreference>
          <uap:Rotation Preference="landscape" />
          <uap:Rotation Preference="landscapeFlipped" />
        </uap:InitialRotationPreference>
      </uap:VisualElements>
    </Application>
  </Applications>
  <Capabilities>
    <Capability Name="internetClient" />
    <!--<DeviceCapability Name="serialcommunication">
      <Device Id="any">
        <Function Type="name:serialPort" />
      </Device>
    </DeviceCapability>
    <DeviceCapability Name="bluetooth.genericAttributeProfile">
      <Device Id="any">
        <Function Type="name:genericAttribute" />
      </Device>
    </DeviceCapability>-->
    <DeviceCapability Name="bluetooth" />
  </Capabilities>
</Package>

在项目属性中,最低Windows版本设置为10.0.15063。可能值得注意的是 - 在尝试tp打包项目的不同变体来解决问题后 - 我有时也会得到“Payload包含两个或更多文件”错误。似乎有很多原因。但是,作为一个(可能有点拙劣)的解决方法,我更改清单中的身份名称,然后它可以工作。我决定稍后解决这个问题,但由于它也可能与主要问题有关,我也想在这里提一下。在过去,我使用nuget包“Win2D.uwp”进行一些可视化,但由于我认为这可能是一个或两个问题的原因,我将其从我的代码和项目中排除并删除了nuget缓存。不幸的是,这也没有帮助......

长话短说:如果有任何人有想法,我会非常感激。也许这是其中一个“哦,你似乎删除了这个重要的声明”的案例。谢谢您的帮助!

c# visual-studio uwp bluetooth-lowenergy windows-10-universal
1个回答
1
投票

将一些分析添加到您的应用程序中,然后进行检查。例如,https://AppCenter.ms。然后你可以检查崩溃日志。您还可以将崩溃日志写入文件,如果您具有对设备的物理访问权限,则进行检查。

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