C# 蓝牙:当我将 app.manifest 添加到项目中时,我的 deviceInformation 有所不同
我使用蓝牙 (BLE) 和 WPF 创建了一个桌面应用程序,但在使用 app.manifest 时遇到问题。对于同一设备,当我使用或不使用 app.manifest 时,我有不同的值(DeviceInformation)。我需要有 app.manifest 并且我希望得到与没有 app.manifest 相同的结果。
我的app.manifest:
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<maxversiontested Id="10.0.18358.0"/>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="bluetooth" />
</Capabilities>
</compatibility>
</assembly>
我的csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<OutputType>WinExe</OutputType>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<Description></Description>
<Title>Test</Title>
<Configuration></Configuration>
<Copyright>Copyright © 2014-2021</Copyright>
<UICulture>fr-FR</UICulture>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Guid>02639d71-0935-35e8-9d1b-9dd1a2a34627</Guid>
</PropertyGroup>
</Project>
我的功能蓝牙:
public void Init(string deviceName)
{
// Get all Edan paired devices
DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(SERVICE_UID)).Completed = (asyncFindDeviceInfo, asyncFindDeviceStatus) =>
{
if (asyncFindDeviceStatus == AsyncStatus.Completed)
{
Device = asyncFindDeviceInfo.GetResults().Where(d => d.Name == deviceName).FirstOrDefault();
}
};
}
结果:
没有app.manifest:DeviceInformation.Name =“EDAN”
有app.manifest:DeviceInformation.Name =“Gatt Service {0000fff0-0000-1000-8000-00805f9b34fb}”
I created a desktop application using Bluetooth (BLE) and WPF but I have a problem when using app.manifest. For the same device I have different values (DeviceInformation) when I use or not app.manifest. I need to have the app.manifest and I would like to have the same result as without.
My app.manifest :
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<maxversiontested Id="10.0.18358.0"/>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
<Capabilities>
<Capability Name="internetClient" />
<DeviceCapability Name="bluetooth" />
</Capabilities>
</compatibility>
</assembly>
My csproj :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<OutputType>WinExe</OutputType>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<Description></Description>
<Title>Test</Title>
<Configuration></Configuration>
<Copyright>Copyright © 2014-2021</Copyright>
<UICulture>fr-FR</UICulture>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Guid>02639d71-0935-35e8-9d1b-9dd1a2a34627</Guid>
</PropertyGroup>
</Project>
My function bluetooth :
public void Init(string deviceName)
{
// Get all Edan paired devices
DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(SERVICE_UID)).Completed = (asyncFindDeviceInfo, asyncFindDeviceStatus) =>
{
if (asyncFindDeviceStatus == AsyncStatus.Completed)
{
Device = asyncFindDeviceInfo.GetResults().Where(d => d.Name == deviceName).FirstOrDefault();
}
};
}
Result :
Without app.manifest : DeviceInformation.Name = "EDAN"
With app.manifest : DeviceInformation.Name = "Gatt Service {0000fff0-0000-1000-8000-00805f9b34fb}"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论