简体   繁体   中英

Windows 10 UWP app closes/crashes immediately after splash screen

I am used to code windows programs using the .net framework. However, since I need to implement a bluetooth low energy connection in my program I familiarized with the UWP and designed an UWP app to connect to a GATT server and read charateristics. The app is more or less based on this Windows BluetoothLE example , but I deleted unused functions and got rid of the frame concept. I can compile and run this app using Visual Studio Community 2017 (15.9.9) on my laptop (Windows 10.0.17763). But I am not able to run this app on other laptops with Windows 10.0.17134, after I created the package and installed it there (prior to installing the developer mode was switched on). The app is available in the start menu and can be started, but I only see the splash screen for some seconds and then the app disappears. Interstingly, I succeded to pack, install and run the original BluetoothLE example as well as a very simple app with only one button based on the UWP template on a 10.0.17134 laptop. So the settings of the system(s) and the packaging process seem to be correct to sideload the app to another laptop.

According to my research so far the problem may be caused by XAML properties in the MainPage.xaml, which can not be processed by the lower Windows version. The MainPage.xaml is:

<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>

Is there a wrong statement or something missing?

Furthermore I tried different changes in the Package.appxmanifest, like reducing the amount of assets-logos to the minimum, which does not help. Note that the bluetooth capability is included (I also tried the bluetooth.genericAttributeProfile, which didn't work and is now commented out). (The serial port part was another test not related to this problem.)

    <?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>

In the project properties, the minimum Windows version is set to 10.0.15063. It may be noticable that - after trying tp pack different variants of the project to solve the problem - I sometimes also get the "Payload contains two or more files" error. There seems to be a bunch of reasons. However, as a (maybe bit botched) workaround I change the Identity Name in the manifest and then it works. I decided to solve that problem later, but since it could also be related to the main problem I prefer to mention it here, too. In the past I used the nuget package "Win2D.uwp" for some visualization, but since I thought this could be a reason for one or both problems I excluded it from my code and project and deleted the nuget cache. Unfortunately, that didn't help, too...

To make a long story short: If anyboby has an idea I would be very thankful. Maybe it is one of these "oh man, it seems you deleted this important statement" cases. Thank you for your help!

Add some analytics to your application, and check it. As example, https://AppCenter.ms . Then you can check crash log. Also you can write crash log to file and check it if you have physical access to device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM