gpt4 book ai didi

适用于 UWP 和经典桌面的 C++ 通用 Windows DLL

转载 作者:太空宇宙 更新时间:2023-11-04 13:03:09 25 4
gpt4 key购买 nike

Universal Windows dll 实际上是通用的,还是仅适用于 UWP?

我正在构建一个具有所有默认值的 native C++ dll,但是当我从经典桌面应用程序(它是一个单元测试)引用它时,我得到了这个异常:

This operation is only valid in the context of an app container.

当然,“Universal Windows”中的“Universal”可能是为那些很酷的人准备的:),但我真的不想为 Windows 10 构建两个单独的 dll,只是因为。

我在为 .NET Core 构建 NuGets 时也注意到了这一点,我将我的 native 库放在 win10 文件夹中。我还有一个针对 Windows 7 的特殊构建,所以它进入了 win7 文件夹。一切看起来都很好,直到运行时,甚至 .NET Core 都无法加载这个通用 dll。

C++ 通用 Windows 是否仅适用于 UWP?有没有办法为 .NET Core、UWP 和经典桌面使用单个 dll?要设置任何特殊标志吗?

如果没有真正通用的 dll,如何区分 Windows 10 dll 是用于 UWP 还是经典桌面?

最佳答案

我和 NuGet 团队讨论过,他们有一个解决方案:

Support for runtimes/{rid}/nativeassets/{tfm}/{any?} was added with #2782

Set a min client version of 3.5.0 in your nuspec to ensure that consumers have the correct client version to pick up this nupkg path.

https://github.com/NuGet/Home/issues/5042

所以对于我的 .nuspec:

<file src="Managed.dll" target="lib\netstandard1.3" />
<file src="Native-Win7.dll" target="runtimes\win7-x64\native" />
<file src="Native-Win10.dll" target="runtimes\win10-x64\native" />
<file src="Native-Uap10.dll" target="runtimes\win10-x64\nativeassets\uap10.0" />

关于适用于 UWP 和经典桌面的 C++ 通用 Windows DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43404666/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com