Error MCG0004:InternalAssert Assert Failed when building UWP app in release mode
Asked Answered
R

1

6

I have an UWP app written in C# which builds (VS 14.0.25425.01 Update 3 on Windows 10.0.14393, target version of the project is build 14393) and runs in Debug mode, but fails to build in Release mode with the following error:

Microsoft.NetNative.targets(640,5): error : MCG0004:InternalAssert Assert Failed: field not found during [UNKNOWN]

There are no further details, except for two warnings before, which I am not sure whether they are related to the problem:

Resources.System.Linq.Expressions.rd.xml(35): warning : ILTransform : warning ILT0027: Method 'CreateLambda' within 'System.Linq.Expressions.Expression' could not be found. Resources.System.Linq.Expressions.rd.xml(91): warning : ILTransform : warning ILT0027: Method 'ParameterIsAssignable' within 'System.Linq.Expressions.Expression' could not be found.

Any suggestions what the issue could be related to?

Rodrigo answered 28/12, 2016 at 17:3 Comment(9)
Got the same issue, seems to be a bug?Reproachful
I assume that with using the link, you mean changing the .csproj to <UseDotNetNativeToolchain>false</UseDotNetNativeToolchain>? I have done this to all three platforms and it fixes the issue.Rodrigo
Yes, please go ahead.Rodrigo
@NicoZhu-MSFT I couldn't find a related issue on GitHub. Is this bug public documented so we can see the progress of it?Reproachful
@Reproachful I am not sure if this is a bug. But here is a similar issue on GitHub.Wheelchair
@NicoZhu-MSFT: Didn't you want to post an answer - I would accept it ;-)Rodrigo
@Rodrigo I'm sorry, if you change the .csproj to <UseDotNetNativeToolchain>false</UseDotNetNativeToolchain> the app will build in debug model. It can't fix the issue really.It may not be right answer.Wheelchair
@NicoZhu-MSFT Do you mean, changing the flag will always build a debug version? Can I submit such a binary to the store at all or would that be rejected?Rodrigo
@Rodrigo I just wanted to submit the app without enabling DotNetNativeToolchain. The Store will not accept such app packages. Disabling UseDotNetNativeToolchain seems not to be the solution I was looking for.Reproachful
C
5

This error will occur if you're using the Beta package for .NET UWP tools with VS 2015. The Beta package is only supported on 2017 as there are changes to how deployment/debugging work that we rely on. You should be able to avoid the issue by downgrading from "Microsoft.NETCore.UniversalWindowsPlatform": "5.3.0-beta2" to "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"

edit: 5.3.0 has been published and works with VS2017 RC3+. More information here: https://blogs.msdn.microsoft.com/dotnet/2017/01/30/announcing-net-core-net-native-and-nuget-updates-in-vs-2017-rc/

Disclaimer: I work on the .NET Native compiler+runtime team.

Childs answered 6/1, 2017 at 0:16 Comment(3)
Glad to hear it. The warnings are completely spurious. See:github.com/dotnet/corefx/issues/5088. They should disappear in the next big update (later this month maybe?)Childs
Thank you @Matt I am not sure why this Error MCG0004:InternalAssert suddenly appeared after many days of working on a project. That error showed up after moving from debug to release for market uploadGrenadier
Release and Debug use different flavors of the .NET stack. DEBUG uses the more user friendly CoreCLR stack while RELEASE uses .NET Native. The reason for this is that the .NET Native compiler/optimizer takes much longer to build applications and greatly reduces productivity during the write>build>debug loop. However, the .NET Native stack leads to applications that start faster and consume less memory which is why it's the shipping configuration for UWP. Hope that helps.Childs

© 2022 - 2024 — McMap. All rights reserved.