- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 .net 5.0 框架的 WPF 应用程序中使用 Windows.Devices.Bluetooth 库。我通过安装 CSWinRT nuget 并在我的 csproj 文件中使用目标框架名字对象来引用 Windows api,如下所示:
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
这不是添加对 windows.winmd 和 windowsruntime.dll 的引用,就像您在 .net5 之前必须做的那样。我可以毫无问题地使用 Windows 库,但我也在使用由使用 .net 4.7.2 的不同项目制作的类库,它也引用/使用 Windows.Devices.Bluetooth 库,这就是我收到此错误的原因:
Severity Code Description Project File Line Suppression StateError CS0012 The type 'BluetoothLEDevice' is defined in an assemblythat is not referenced. You must add a reference to assembly 'Windows,Version=255.255.255.255, Culture=neutral, PublicKeyToken=null,ContentType=WindowsRuntime'. 128 Active
所以我可以直接访问库,但不能通过 dll。可能是 dll 使用不同的框架的问题?
有人知道怎么解决吗?
最佳答案
对此的解决方案是升级类库项目 .net 5,以便两个项目都使用相同的框架。
关于c# - 使用 CSWinRT 调用 .net5 windows api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67806196/
我在使用 .net 5.0 框架的 WPF 应用程序中使用 Windows.Devices.Bluetooth 库。我通过安装 CSWinRT nuget 并在我的 csproj 文件中使用目标框架名
我是一名优秀的程序员,十分优秀!