-
Notifications
You must be signed in to change notification settings - Fork 509
samples/WebApi doesn't work with .NET Core 2.1 #5720
Comments
ASP.NET dependency injection introduced dependency on Reflection.Emit in aspnet/DependencyInjection#630 unfortunately. It makes it incompatible with CoreRT. We can make it functional in CoreRT AOT environment by introducing IL interpretter (#5011), but it would still perform poorly. The dependency injection framework is using Reflection.Emit on performance critical paths. It would be really up to ASP.NET to provide AOT-friendly flavor that generates all code at build time instead of runtime to make this work well. It would likely help the startup without CoreRT as well. |
That's annoying. Thanks for the explanation though. |
It may be possible to workaround this by using netstandard2.0 build of DependencyInjection that does not have the dependency on Reflection.Emit: https://github.com/aspnet/DependencyInjection/pull/630/files#diff-499bed1ac3743837d217bcbe8bad072fR9 |
It looks like ASP.NET might have also kept the expression-based DI engine based on ServiceProviderOptions.Mode (along with a couple other modes that might be faster than expressions while still AoT friendly). I'd suggest seeing if there's a way to control that from user code. |
Is there any way I can force the build to use the |
Hmm... outside of the incredibly hacky "add a pre-build step to modify the I'm away from my project at the moment, but I'll try that when I get back to it. |
If only we had this https://github.com/dotnet/corefx/issues/10470 😏 |
Actually this also breaks some other projects that are not using Microsoft.AspNetCore* namespaces directly. This is a bit annoying^^ Btw: It also happens when using netcoreapp2.0 |
This issue seems to be fixed? Just tested it and it works fine. |
@Fabi according to a comment in aspnet/home#3079 we should really be fine for 2.1. Thanks for verifying this! |
Doesn't work for 2.1 |
Probably another issue |
Same issue
|
I wonder if it's barfing at the reference itself. I would hope not... |
For what I'm trying to build the only use/reference of DI would be via I'm trying to build the PlatformBenchmark with json and db stuff stripped out, so is very basic and doesn't use DI directly. However I have updated the Sample to show the issue #5912 |
The compiler is crashing because the facade assemblies that CoreFX is generating for Ref.Emit are bogus. I filed #5913 on the compiler crash (we shouldn't crash), but this would ideally be fixed by making the Ref.Emit behave like any other other API we don't currently support in CoreRT (i.e. a bunch of |
We're waiting for dotnet/corefx#30338 to get through. After that, we'll pick up the latest CoreFX and the problem with bogus Ref.Emit facades should be gone. |
#5953 has the fixes to CoreFX that should make this compile again. |
I encountered this on my own project, so I tried with the WebApi sample and got the same issue.
I tested before changing anything and everything worked.
I updated the
csproj
file to use 2.1 instead of 2.0, so it now looks like this:I had to remove the
Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv
entry fromrd.xml
because 2.1-preview2 no longer useslibuv
.With those changes, when I ran
dotnet publish -c Release -r win-x64
I got the following output:Environment info
Windows 10 Pro 1709 Build 16299.371
The text was updated successfully, but these errors were encountered: