core icon indicating copy to clipboard operation
core copied to clipboard

System.memory nuget package causing .net native fail

Open AnthroHeader opened this issue 8 years ago • 7 comments

I'm attempting to use the System.Memory nuget package for Span<T> support in my UWP app. Unfortunately, while everything works in debug, compiling in release mode using the .net native toolchain fails with the following error message:

Internal compiler error: Object reference not set to an instance of an object.
C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets	697

The project I'm working on is open source and available here.

AnthroHeader avatar Jun 19 '18 12:06 AnthroHeader

Tested a bit more, it seems it works if I set the minimum required UWP SDK to 16299. Unfortunately as I'm targeting phones too I need to keep 15063 as the baseline.

AnthroHeader avatar Jun 20 '18 11:06 AnthroHeader

@nattress do you have a place where .Net Native issues are tracked? We could move this to corefx.

Petermarcu avatar Jun 21 '18 20:06 Petermarcu

@Petermarcu Not on Github. corefx would probably be a good place for this question.

@albertofustinoni Span<T> support was only recently added for UWP apps. It is unfortunately not available pre-16299 so if you want to keep 15063, you'll be unable to use Span<T>. You'd have to roll forward to version 6.1.5 of the Microsoft.NETCore.UniversalWindowsPlatform package in your app project.

nattress avatar Jun 21 '18 23:06 nattress

Ok, I think that answers the question though. I'm going to close this issue here as the solution is to move to a newer version and we don't plan to bring it to older versions.

Petermarcu avatar Jun 22 '18 00:06 Petermarcu

@nattress This doesn’t make sense to me: System.Memory is .net standard 1.1 (check Nugget) and UWP pre Fall Creators Update supports up to 1.4.

How can it not be compatible, especially when UWP debug builds work perfectly and other netstandard 1.4 assemblies I have that reference it work fine too?

AnthroHeader avatar Jun 22 '18 00:06 AnthroHeader

@albertofustinoni Unfortunately a feature like Span is not just implemented in the library layer. It requires runtime support. In UWP debug mode, the CoreCLR runtime is used to run your app. It has Span support. When you deploy your app in release mode, the .NET Native ahead-of-time (AOT) compiler is used. This compiler had Span support added later than CoreCLR. As a result the newer version is needed.

nattress avatar Jun 22 '18 00:06 nattress

@nattress Ok now that makes sense. Thank you for your explanation. It’s just very saddening to see Windows 10 mobile die like this.

AnthroHeader avatar Jun 22 '18 09:06 AnthroHeader