I have a solution with two UWP projects. One is a library with shared code and the other is a regular UWP app that references the library.
I have successfully developed the app running it in Debug mode. Now I must pack it to the store, that's where NET has given me trouble.
When I compile it in release mode I get the following error
C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x64\ilc\IlcInternals.targets(936,5): error :
System.TypeLoadException: Could not resolve type 'System.Collections.Generic.ISet`1'.
in System.TypeNameParser.ResolveType(Assembly assembly, String[] names, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
in System.TypeNameParser.ConstructType(Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
in System.TypeNameParser.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
in System.Type.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError)
in System.Reflection.Adds.TypeNameParser.ParseTypeName(ITypeUniverse universe, Module module, String input, Boolean throwOnError)
in Microsoft.MetadataReader.MetadataExtensionsPolicy20.TryTypeForwardResolution(MetadataOnlyAssembly assembly, String fullname, Boolean ignoreCase)
in Microsoft.MetadataReader.MetadataOnlyAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
in Microsoft.MetadataReader.MetadataOnlyAssembly.GetType(String name, Boolean throwOnError)
in SerializationAssemblyGenerator.Program.TraverseTypes(GeneratorSettings settings, Dictionary`2& dataContracts, Dictionary`2& jsonDataContracts, List`1& xmlSerializerTypes)
in SerializationAssemblyGenerator.Program.Main(String[] args)
I use ISet a lot so it's natural it is referenced. I have the Microsoft.NETCore.UniversalWindowsPlatform package version 5.2.2 installed, so I assume its available here. I tried downgrading to version 5.1 but I get the same error. Same if I install the System.Collections package.
So, I finally made it work. It involved starting another library and moving code from the original, util I caught the problematic class. Very boring as Net Native is soooooo slooooow.
And the culprit was:
private async Task Serialize(ISet<Server> data)
this small function serialized a preferences collection using a MemoryStream and DataContractJsonSerializer.
When I changed the signature to
private async Task Serialize(HashSet<Server> data)
worked like a charm.
Hope this helps someone in the future.