我习惯使用.net框架对Windows程序进行编码。但是,由于我需要在程序中实现蓝牙低能耗连接,因此我熟悉了UWP,并设计了一个UWP应用程序以连接至GATT服务器并读取特性。该应用程序或多或少基于this Windows BluetoothLE example,但是我删除了未使用的功能并摆脱了框架的概念。 我可以在笔记本电脑(Windows 10.0.17763)上使用Visual Studio Community 2017(15.9.9)编译并运行此应用程序。但是,在创建程序包并将其安装到Windows 10.0.17134之前,我无法在其他装有Windows 10.0.17134的笔记本电脑上运行该应用程序(在打开开发人员模式之前已打开)。该应用程序在开始菜单中可用并且可以启动,但是我只看到启动屏幕几秒钟,然后该应用程序消失了。 有趣的是,我成功打包,安装并运行了原始的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打包项目的不同变体来解决问题后,有时我还会收到“有效负载包含两个或多个文件”错误。似乎有很多原因。但是,作为一种(可能有点拙劣的)解决方法,我在清单中更改了身份名称,然后它起作用了。我决定稍后再解决该问题,但是由于它也可能与主要问题有关,因此我也想在此提一下。 过去,我使用nuget软件包“ Win2D.uwp”进行可视化,但是由于我认为这可能是一个或两个问题的原因,因此将其从代码和项目中排除,并删除了nuget缓存。不幸的是,这也无济于事...
长话短说:如果任何人都有想法,我将非常感激。可能是这些“哦,伙计,您似乎删除了此重要声明”案例之一。谢谢您的帮助!
答案 0 :(得分:1)
向您的应用程序添加一些分析,然后进行检查。 例如,https://AppCenter.ms。然后,您可以检查崩溃日志。您还可以将崩溃日志写入文件,并检查它是否对设备具有物理访问权限。