We have an app that compiles fine without the .NET Native tool chain, but when we click this checkbox, we get these compilation errors (Debug or Release):
*Severity Code Description Project File Line Suppression State
Error at SerializationAssemblyGenerator.Program.GenerateDataContractSerializerHelper(IEnumerable`1 contracts, IEnumerable`1 jsonContracts, GeneratorSettings settings, String intermediateAssembly, IEnumerable`1 wcfSerializers) Adapt.Presentation.Helpdesk.UWP C:\Users\chris\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets 691
Error at SerializationAssemblyGenerator.Program.Main(String[] args) Adapt.Presentation.Helpdesk.UWP C:\Users\chris\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets 691
Error ILT0032: Failed to compile serialization code. See the build log for error details. Adapt.Presentation.Helpdesk.UWP C:\Users\chris\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets 691
Error at SerializationAssemblyGenerator.Program.GenerateDataContractSerializerHelperCode(IEnumerable`1 contracts, IEnumerable`1 jsonContracts, IEnumerable`1 wcfSerializers) Adapt.Presentation.Helpdesk.UWP C:\Users\chris\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets 691
Error at SerializationAssemblyGenerator.Program.AddKnownContractsLists(McgCodeTypeDeclaration container, ContractTables tables) Adapt.Presentation.Helpdesk.UWP C:\Users\chris\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets 691
Error at System.Collections.Generic.Dictionary`2.get_Item(TKey key) Adapt.Presentation.Helpdesk.UWP C:\Users\chris\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets 691
Error System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. Adapt.Presentation.Helpdesk.UWP C:\Users\chris\.nuget\packages\microsoft.net.native.compiler\1.6.2\tools\Microsoft.NetNative.targets 691*
There are a lot of errors in the output window. There's far too much to post here, but here are a couple of hints:
*1> C:\AdaptSource\Xivic\Adapt.Presentation.Helpdesk.UWP\obj\x86\Debug\ilc\in\System.Reflection.Extensions.dll
1> The assembly 'System.Reflection.Metadata.dll' is found in more than one folder.
1> file:///C:/AdaptSource/Xivic/Adapt.Presentation.Helpdesk.UWP/obj/x86/Debug/ilc/in/System.Reflection.Metadata.dll*
I thought that perhaps there were DLLs floating around and it was getting confused about which one to use, but this still occurred even after a full Git clean.
This is the Default.rd.xml
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />
<!-- Add your application specific runtime directives here. -->
</Application>
</Directives>
From everything I've come to understand, this should include all the types in our solution. Is this assumption correct?
I have a feeling that it has something to with specifying metadata for the types that exist in our project. There is an article here that hints at this: https://learn.microsoft.com/en-us/dotnet/framework/net-native/getting-started-with-net-native. But, I don't really understand what it is asking me to do, so I'm stuck.
Add a reference to each assembly that is referenced by the app. For more you could refer to Target Invocation Exception.