使用StoreContext时,发布模式下的.NET本机序列化异常



我想在我的UWP应用程序中管理一些插件。应用程序的目标是Windows 10秋季创建者更新(均为16299 SDK)的最低/目标。

我有一个名为LicenseHelper的类,它使用Windows.Services.Store命名空间下的StoreContext类。调试模式下一切都很好。但是,如果我想在x64和x86架构的发布模式下构建,编译器会抛出以下序列化错误:

Generating serialization code
2>  Compiling interop code
2>C:UsersBurak.nugetpackagesmicrosoft.net.native.compiler2.1.8toolsMicrosoft.NetNative.targets(788,5): error : Error generating serialization code for the root type SimpleStream.Helpers.LicenseHelper: Cannot find the assembly 'Windows.Services.Store.StoreContract' in the probing directories.
2>  Generating System.Reflection.DispatchProxy proxy code.
2>C:UsersBurak.nugetpackagesmicrosoft.net.native.compiler2.1.8toolsMicrosoft.NetNative.targets(788,5): error : ILT0032: Failed to compile serialization code. See the build log for error details.

如果我删除了与StoreContext相关的所有内容,那么构建就可以了。StoreContract结构在任何地方都没有直接使用。仅仅一个简单的StoreContext定义就足以使编译器在发布版本上的序列化失败。

另一件事是,我曾经让它工作。使用StoreContext的第一个包已经在商店中,具有相同的设置,如min/target SDK版本和.NET Core UWP包(6.1.9)。不知道为什么它不再工作。

尝试将.NET Core nuget升级为预览版,但降级一点也无济于事。

这可能是编译器的内部错误,甚至是sdk本身的错误,但我不知道。

这背后的原因是什么?

在这种情况下,我认为这是一个兼容性问题,Prism不完全支持最新的Windows版本。

StoreContext文档对此给出了一些指示。

https://learn.microsoft.com/en-us/uwp/api/Windows.Services.Store.StoreContext