.netuwp.net-native

.NET Native serialization exception in Release mode when using StoreContext


I want to manage a few add-ons in my UWP application. Application is targeting minimum/target for Windows 10 Fall Creators Update (both 16299 SDK).

I have a class called LicenseHelper and it uses StoreContext class under Windows.Services.Store namespace. Everything builds fine on debug mode. However, compiler throws the following serialization error if I want to build in Release mode for x64 and x86 architechtures:

Generating serialization code
2>  Compiling interop code
2>C:\Users\Burak\.nuget\packages\microsoft.net.native.compiler\2.1.8\tools\Microsoft.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:\Users\Burak\.nuget\packages\microsoft.net.native.compiler\2.1.8\tools\Microsoft.NetNative.targets(788,5): error : ILT0032: Failed to compile serialization code. See the build log for error details.

If I remove everything related to StoreContext, build is just fine. There is no direct usage of StoreContract struct anywhere. Just a simple StoreContext definition is enough to compiler to fail serialization on Release builds.

Another thing is, I used to have it working. The first package that uses StoreContext is already in the store with the same settings like min/target SDK versions and .NET Core UWP package (6.1.9). Have no idea why it's not working anymore.

Tried upgrading .NET Core nuget to preview ones and downgrading them a bit even didn't help.

It might me an internal bug with the compiler or even the sdk itself but I don't know.

What could be the reason behind this?


Solution

  • Well in this case I believe this a compatibility issue that, Prism doesn't fully support the latest Windows versions.

    StoreContext documentation gives some indication on this.

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