UWP builds failing with .NetNative compile and WACK Test fails with unchecked Optimized code

Hi All,

We are trying to make one UWP build targeted for PC with latest installed SDK.
We are able to make solution file, but having trouble making app package.(may be some settings need to be changed)
I am adding all our test cases. Any leads on this will be helpful.

We are basically stuck in between .Net Native Compile tool chain, Optimize code and Default.rd.XML.
Just to add on this, we do have couple of third party dll’s in our project like Newtonsoft.Json, DOTween, Smart-Fox etc…

Case 1:
If .Net Native and optimize code both are checked, we get following errors:
1>MSBuild\15.0.Net.NetNative\15.0.24211\x64\ilc\IlcInternals.targets(1192,5): error : Method ‘PropertyDispatcherFactory.Accessor(PropertyInfo, SetOrGet)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
1> Method ‘SliceDispatcherFactory.CreateSetter(MemberInfo)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
1>error : Method ‘SliceDispatcherFactory.d__f.MoveNext()’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
1> Method ‘ExtensionRegistry.AddExtensionMembers(List, Type)’ will always throw an exception due to the missing method ‘Type.GetMembers(BindingFlags)’. There may have been a missing assembly.
1> error : ILT0005: ‘C:\Program Files (x86)\MSBuild\15.0.Net.NetNative\15.0.24211\x64\ilc\Tools\nutc_driver.exe @“C:\FOlder\obj\x64\Master\ilc\intermediate\MDIL\App.rsp”’ returned exit code 1

Case 2:

.Net Native unchecked.

We tried this options first, just to check if build runs. Although I read .Net Native compile tool chain has to be checked in order to submit to the app store.
Am I right?
Anyways build did ran, but failed WACK Test with the following errors:

Error Found: The supported APIs test detected the following errors:
API ExecuteAssembly in uwphost.dll is not supported for this application type. App.exe calls this API.
API DllGetActivationFactory in uwphost.dll is not supported for this application type. App.exe has an export that forwards to this API.

Case 3:
Later we tried with .NetNative checked and unchecking optimize code

Build was successful, but WACK again failed this time with following errors:

Supported APIs
Error Found: The supported APIs test detected the following errors:
API CoCreateInstance in api-ms-win-core-com-l1-1-0.dll is not supported for this application type. SoD.dll calls this API.

For the 3rd Case:
We tried searching on some forums found this link:
__Issues · dotnet/efcore · GitHub

But then again could really came to pinpoint which library or assembly is causing the issue.

Following link showed the guy had the issue with Newtonsoft.Json and mentionning he unchecked optimized code and excluded the assembly from Default.rd.xml.
__https://forums.xamarin.com/discussion/70305/uwp-and-azuremobileservice-offline-sqlite-sync-problem-when-building-with-net-native-toolchain-on__

So I tried adding our Libraries like this:








We also tried updating .Net Native through NuGet!
Is there anything we might be missing?

Any help is appreciated!
Thanks in Advance
Deepesh

You’re right.

Did you by any chance modify the project.json file in the Unity-generated UWP project? Could you paste its contents?

Hi Tautvydas,

Thanks for the response!
No, we haven’t updated the project.json file. I am attaching the content below:

{
“dependencies”: {
“Microsoft.ApplicationInsights”: “1.0.0”,
“Microsoft.ApplicationInsights.PersistenceChannel”: “1.0.0”,
“Microsoft.ApplicationInsights.WindowsApps”: “1.0.0”,
“Microsoft.NETCore.UniversalWindowsPlatform”: “5.0.0”
},
“frameworks”: {
“uap10.0”: {}
},
“runtimes”: {
“win10-arm”: {},
“win10-arm-aot”: {},
“win10-x86”: {},
“win10-x86-aot”: {},
“win10-x64”: {},
“win10-x64-aot”: {}
}
}

with these settings and unchecking optimize code. I was able to make a package but WACK test failed.

Just wanted to add some info to this, today I tried updating Microsoft.NETCore.UniversalWindowsPlatform to 5.4.1 version this time I couldn’t even made the build.

Even tried updating it to 6.0.2, still same erros, with check or uncheck optimize code.
Something like:
.native.compiler\1.7.1\tools\Microsoft.NetNative.targets(697,5): error : Type ‘Windows.Foundation.Collections.IMap2' was not included in compilation, but was referenced in method 'BootstrapHelpers.FillTypeMaps2(Dictionary<Type, int>, List<Type>)'. There may have been a missing assembly.* *.native.compiler\1.7.1\tools\Microsoft.NetNative.targets(697,5): error : Type 'Windows.Foundation.Collections.IVectorView1’ was not included in compilation, but was referenced in method ‘BootstrapHelpers.FillTypeMaps2(Dictionary<Type, int>, List)’. There may have been a missing assembly.
.native.compiler\1.7.1\tools\Microsoft.NetNative.targets(697,5): error : Type ‘Windows.Foundation.DateTime’ was not included in compilation, but was referenced in method ‘BootstrapHelpers.FillTypeMaps2(Dictionary<Type, int>, List)’. There may have been a missing assembly.

Also attached the log errors I got later on updating .net.

3308549–256862–updating dot Net.txt (12.8 KB)

Can we get a bug report on this? Unfortunately it’s very hard to diagnose what is going wrong from just the log.

Which Unity version are you on? Did you try switching to IL2CPP to workaround your issues? I understand that might introduce new ones, but it might still be worth a shot.

Hi Tautvydas,

Unity version which we are using is 2017.20f3.
Problem is just seeing this, we are not able to narrow down which files are actually creating problem.
I could have shared Visual studio solution project, but with that help? it might have reference missing, since solution was made on local system.

If there’s a way please let me know.

Yes we tried switching the project to IL2CPP. WACK test got passed too.
But we started getting runtime errors like:

System exception caught: System.DllNotFoundException: Unable to load DLL ‘kernel32.dll’: The specified module could not be found.
at Microsoft.Win32.UnsafeNativeMethods.GetModuleHandle (System.String moduleName) [0x00000] in <00000000000000000000000000000000>:0
Index was outside the bounds of the array.
at System.Globalization.DateTimeFormatInfo.GetMonthName (System.Int32 month)

I also found something similar here:

https://docs.unity3d.com/Manual/windowsstore-missingtypes.html

Also would we be able to submit this app, if we somehow resolve these issues?

Thanks,
Deepesh

Finding what’s causing it on .NET scripting backend could be challenging… I’m not entirely familiar with .NET Native internals myself. For starters, do you get any errors in Unity console when building for UWP with .NET scripting backend?

As for IL2CPP issues:

What’s the full callstack for the first exception?

The second exception was fixed in 2017.2.0p2 - so you’d just have to update Unity to work around it.

IL2CPP builds can be submitted to the Windows Store without any issues.

Hi Tautvydas,

When making the build with .NET backend, it is not giving us any errors in Unity console, but lot of warnings.

We tried using 2017.2 0p2, and the second error got fixed.
Many thanks for that!

The first exception I guess is with XML serializer.

Following is the callstack:

System exception caught: System.DllNotFoundException: Unable to load DLL ‘kernel32.dll’: The specified module could not be found.
at Microsoft.Win32.UnsafeNativeMethods.GetModuleHandle (System.String moduleName) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.Win32.UnsafeNativeMethods.DoesWin32MethodExist (System.String moduleName, System.String methodName) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.Win32.UnsafeNativeMethods._IsPackagedProcess () [0x00000] in <00000000000000000000000000000000>:0
at System.Lazy1[T].CreateValue () [0x00000] in <00000000000000000000000000000000>:0* *at System.Lazy1[T].LazyInitValue () [0x00000] in <00000000000000000000000000000000>:0
at System.Lazy`1[T].get_Value () [0x00000] in <00000000000000000000000000000000>:0
at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly (System.Type type, System.String defaultNamespace, System.Xml.Serialization.XmlSerializerImplementation& contract) [0x00000] in <00000000000000000000000000000000>:0
at System.Xml.Serialization.XmlSerializer…ctor (System.Type type, System.String defaultNamespace) [0x00000] in <00000000000000000000000000000000>:0

I also found there is an active bug with Unity:

We tried changing the API compatibility level back to .Net2.0, but then other errors came with different dll’s including Unity.Purchasing while making the build itself.

We are looking into this, but just wanted to check with you if there’s a workaround for XML serializing?

Thanks,
Deepesh

The only workaround I can offer regarding XML serialization is to use different serialization code that do not depend on System.Xml namespace - there are few on github.

What kind of warnings do you get on .NET scripting backend?

Hi Tautvydas,

Warnings which we get right now are mostly with some API’s deprecated like:

Assets/PlugIns/UnityChannel/XiaomiSupport/Editor/AppStoreOnboardApi.cs(46,12): warning CS0618: UnityEngine.Networking.UnityWebRequest.Send()' is obsolete: Use SendWebRequest. It returns a UnityWebRequestAsyncOperation which contains a reference to the WebRequest object.’
UnityEngine.GUITexture' is obsolete: This component is part of the legacy UI system and will be removed in a future release.’
warning CS0109: The member ‘PieceRemover.renderer’ does not hide an inherited member. The new keyword is not required.
warning CS0618: ‘GUITexture’ is obsolete: ‘This component is part of the legacy UI system and will be removed in a future release.’
‘RuntimePlatform.MetroPlayerARM’ is obsolete: ‘Use WSAPlayerARM instead’
UnityEditor.EditorUserBuildSettings.SwitchActiveBuildTarget(UnityEditor.BuildTarget)' is obsolete: Please use SwitchActiveBuildTarget (BuildTargetGroup targetGroup, BuildTarget target)’

Although we get error when we try to make a package. Errors are:

Type ‘Windows.System.Profile.HardwareToken’ was not included in compilation, but was referenced in method ‘DeviceContextReader.GetDeviceUniqueId()’. There may have been a missing assembly. SoD
Error Method ‘DeviceContextReader.GetDeviceUniqueId()’ will always throw an exception due to the missing method ‘HardwareIdentification.GetPackageSpecificToken(IBuffer)’. There may have been a missing assembly. SoD
Error Method ‘ExtensionRegistry.AddExtensionMembers(List, Type)’ will always throw an exception due to the missing method ‘Type.GetMembers(BindingFlags)’. There may have been a missing assembly. SoD
Error Method ‘PropertyDispatcherFactory.Accessor(PropertyInfo, SetOrGet)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly. SoD
Error Type ‘Windows.System.Profile.HardwareIdentification’ was not included in compilation, but was referenced in method ‘DeviceContextReader.GetDeviceUniqueId()’. There may have been a missing assembly. SoD
Error Method ‘SliceDispatcherFactory.d__f.MoveNext()’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly. SoD
Error ILT0005: ‘C:\Program Files (x86)\MSBuild\15.0.Net.NetNative\15.0.24211\x64\ilc\Tools\nutc_driver.exe @“C:\Builds\DOMain\Metro\CL156761\DOMain_QA_BUILD_CL156761\SoD\obj\x64\Master\ilc\intermediate\MDIL\SoD.rsp”’ returned exit code 1 SoD
Error Method ‘SliceDispatcherFactory.CreateSetter(MemberInfo)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly. SoD

We tried searching for few free ones which might support runtime xml serialization with IL2CPP like:

ZeroFormatter, MessagePacker.
But they support only Pre-generated code. having tags on each XML element and node.
That might be an overhead for us( we have a lot of XML structures).
Their repository have also mentioned the same
" It can not use dynamic serializer generation due to IL2CPP issue"

Was these kind of serialization code you were referring too? or did I miss something?

Thanks,
Deepesh

I found this one on Github: SharpXml/SharpXml at master · kongo2002/SharpXml · GitHub

As for .NET native issue - sorry, I honestly have no idea. We’ll need a bug report in order to investigate that issue properly.

I have the same problem on 3.0b10:

ERRORS:
Method ‘PropertyDispatcherFactory.Accessor(PropertyInfo, SetOrGet)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
Method ‘ExtensionRegistry.AddExtensionMembers(List, Type)’ will always throw an exception due to the missing method ‘Type.GetMembers(BindingFlags)’. There may have been a missing assembly.
Method ‘SliceDispatcherFactory.d__f.MoveNext()’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
Internal compiler error: Index was out of range. Must be non-negative and less than the size of the collection.__Parameter name: index
Method ‘SliceDispatcherFactory.CreateSetter(MemberInfo)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.

WARNINGS:
‘ApplicationView.SuppressSystemOverlays.set’ is obsolete: 'Use the TryEnterFullScreen method and IsFullScreenMode property instead of SuppressSystemOverlays.
ILTransform_0003: Method ‘SliceDispatcherFactory.d__f.MoveNext()’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
ILTransform_0003: Method ‘PropertyDispatcherFactory.Accessor(PropertyInfo, SetOrGet)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
ILTransform_0003: Method ‘SliceDispatcherFactory.CreateSetter(MemberInfo)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
ILTransform_0003: Method ‘ExtensionRegistry.AddExtensionMembers(List, Type)’ will always throw an exception due to the missing method ‘Type.GetMembers(BindingFlags)’. There may have been a missing assembly.
Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.

ETA: The project builds and runs fine on RELEASE, just not on MASTER.

Hey Magg,

We are also trying to find a fix for this for .Net, no luck as of yet.

It runs fine with release tag because their “Optimized Code” is unchecked.

You can change your master configuration too, just go to your project properties and under “Build” tab.

But with this WACK test is failing. Just an FYI.

Well, I’ve created a new UWP project with a simple VR scene and everything builds fine.
So I’m trying to add assets one by one to see what’s the problem and the

“Internal compiler error: Index was out of range. Must be non-negative and less than the size of the collection.__Parameter name: index”

error was caused by Playmaker’s Pathfinding package. PM base is fine. I’m using PM for scripted events as I was too lazy to write them myself.

Not sure about the rest yet, but I’m gonna find out.
Will report back.

Went back to my main project and removed everything that had to do with Playmaker. It builds and runs fine.
No errors, but I still get these warnings:

Warning ILTransform_0003: Method ‘PropertyDispatcherFactory.Accessor(PropertyInfo, SetOrGet)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
Warning ILTransform_0003: Method ‘SliceDispatcherFactory.d__f.MoveNext()’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.
Warning ILTransform_0003: Method ‘ExtensionRegistry.AddExtensionMembers(List, Type)’ will always throw an exception due to the missing method ‘Type.GetMembers(BindingFlags)’. There may have been a missing assembly.
Warning ILTransform_0003: Method ‘SliceDispatcherFactory.CreateSetter(MemberInfo)’ will always throw an exception due to the missing method ‘PropertyInfo.GetSetMethod(bool)’. There may have been a missing assembly.

Hey Magg,

Good to hear you have a error free build. We are almost on to it too, can’t pin pint the code though.
Regarding the warnings, I guess you can ignore them. Even when they use to come previously as errors
Its a Visual studio thing, if there’s a compiler error, visual studio will throw last warnings as compiler errors too.
Also GetMethod and GetType in .Net subset are defined up to an extent not fully.
May be some library is calling it internally.

My 5 cents on this.

I’m on 2017.3.p3 and get the same errors as DeepeshMishra mentioned in 1st post.
After 2 days of ivestigations i coudn’t find any issues with my dll’s or libraries and i use a few(Playmaker, leantween, json etc).
I want to mention that my project was migrated over the time form one version of unity to another. I did created a new project and just moved to it all contents of Assets folder. After that i did compiled everything and , “Master” setup get compiled with no errors, magic!

Still don’t understand this behaviour.
Cheers

P.S. it get compiled because errors has been transformed into warnings ><

3>C:\Program Files (x86)\MSBuild\15.0\.Net\.NetNative\15.0.24211\x64\ilc\IlcInternals.targets(936,5): warning : ILTransform_0003: Method 'PropertyDispatcherFactory.Accessor(PropertyInfo, SetOrGet)' will always throw an exception due to the missing method 'PropertyInfo.GetSetMethod(bool)'. There may have been a missing assembly.
3>C:\Program Files (x86)\MSBuild\15.0\.Net\.NetNative\15.0.24211\x64\ilc\IlcInternals.targets(936,5): warning : ILTransform_0003: Method 'SliceDispatcherFactory.CreateSetter(MemberInfo)' will always throw an exception due to the missing method 'PropertyInfo.GetSetMethod(bool)'. There may have been a missing assembly.
3>C:\Program Files (x86)\MSBuild\15.0\.Net\.NetNative\15.0.24211\x64\ilc\IlcInternals.targets(936,5): warning : ILTransform_0003: Method 'SliceDispatcherFactory.<Setters>d__f.MoveNext()' will always throw an exception due to the missing method 'PropertyInfo.GetSetMethod(bool)'. There may have been a missing assembly.
3>C:\Program Files (x86)\MSBuild\15.0\.Net\.NetNative\15.0.24211\x64\ilc\IlcInternals.targets(936,5): warning : ILTransform_0003: Method 'ExtensionRegistry.AddExtensionMembers(List<MemberInfo>, Type)' will always throw an exception due to the missing method 'Type.GetMembers(BindingFlags)'. There may have been a missing assembly.
1 Like

Hey!

Did you solve your issue eventually?

Thanks :slight_smile:

Changing the PC helped me. So if some of you have this issue you can try to change your PC or reinstall Windows

@Liviuss advice is very good too.

I wish the good releases to everyone! :slight_smile: