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?

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
Christoph
  • 1,964
  • 2
  • 27
  • 44
  • Got the same issue, seems to be a bug? – Briefkasten Dec 28 '16 at 20:52
  • I assume that with using the link, you mean changing the .csproj to  `false`? I have done this to all three platforms and it fixes the issue. – Christoph Dec 29 '16 at 11:24
  • Yes, please go ahead. – Christoph Dec 30 '16 at 11:59
  • @NicoZhu-MSFT I couldn't find a related issue on GitHub. Is this bug public documented so we can see the progress of it? – Briefkasten Dec 30 '16 at 15:36
  • @Briefkasten I am not sure if this is a bug. But here is a similar issue on [GitHub](https://github.com/dotnet/corefx/issues/5088). – Nico Zhu Jan 02 '17 at 02:05
  • @NicoZhu-MSFT: Didn't you want to post an answer - I would accept it ;-) – Christoph Jan 02 '17 at 15:07
  • @Christoph I'm sorry, if you change the .csproj to `false` the app will build in debug model. It can't fix the issue really.It may not be right answer. – Nico Zhu Jan 03 '17 at 01:33
  • @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? – Christoph Jan 03 '17 at 11:25
  • @Christoph 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. – Briefkasten Jan 03 '17 at 15:44

1 Answers1

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.

MattWhilden
  • 1,686
  • 13
  • 18
  • Glad to hear it. The warnings are completely spurious. See:https://github.com/dotnet/corefx/issues/5088. They should disappear in the next big update (later this month maybe?) – MattWhilden Jan 06 '17 at 22:03
  • 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 upload – jaysonragasa Jan 24 '17 at 06:21
  • 1
    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. – MattWhilden Jan 24 '17 at 21:57