C# 蓝牙:当我将 app.manifest 添加到项目中时,我的 deviceInformation 有所不同

发布于 2025-01-09 18:25:04 字数 2624 浏览 3 评论 0原文

我使用蓝牙 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文