aspnetcore: `TypeLoadException`s on .NET 9 when referencing HttpSys on Linux
YARP will try to grab the IServerDelegationFeature on startup to detect if the functionality is supported.
_serverDelegationFeature = server.Features?.Get<IServerDelegationFeature>();
We’re seeing many users run into TypeLoadExceptions when upgrading their app from .NET 8 to 9:
https://github.com/microsoft/reverse-proxy/issues/2652
System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Server.HttpSys.IServerDelegationFeature' from assembly 'Microsoft.AspNetCore.Server.HttpSys, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Yarp.ReverseProxy.Delegation.HttpSysDelegator..ctor(IServer server, ILogger`1 logger)
Reports mention both Ubuntu 22 and 24. I was not able to reproduce the issue myself (on a VM nor WSL).
Possibly a recent regression since RC2? https://github.com/microsoft/reverse-proxy/issues/2652#issuecomment-2490491555
To give some extra confusion, we’ve been running our test envoirment on 9RC1 and 9RC2 when they came out, and didn’t have the issue, they only came with the official release (I use ./dotnet-install.sh, no apt since it wasn’t released there yet).
What sort of information would be needed to help diagnose this?
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 37 (28 by maintainers)
The YARP 2.3.0 release with the workaround for this issue is now available. https://github.com/dotnet/yarp/releases/tag/v2.3.0
The missing APIs mean in 9.0 it’s impossible to write a cross-platform app or library (like YARP) that uses Http.Sys on Windows and Kestrel on Linux, because even referencing Http.Sys causes this crash on Linux. I don’t know how common that is, but some basic fix should be made in 9.0. YARP users noticed really fast…
We have a new version of .NET 9, a patch release that was recently released, and yet the issue has not been resolved. This is blocking us from deploying .NET 9 to production with our projects.
making one right now
Hoping next week. There are a couple of PRs we are trying to get in before the release.
@omajid I’d like us to get to the bottom of that as well (and the process issues that led to this not being discovered in time to resolve it before 9.0). However, those things will certainly take more time than this workaround in YARP so I think it’s best to start with this.
It seems like this is probably the most likely case people will run into this issue anyway… there’s not many other reasons why someone would be trying to do anything related to HTTP.sys if they’re on Linux.
FWIW there are two ways to workaround this issue, so it shouldn’t be totally blocking:
dotnet-install.shinstead: https://learn.microsoft.com/dotnet/core/tools/dotnet-install-scriptI can only reproduce this with the
dotnet-sdk-9.0package, not on any build fromdotnet-install.sh, so the source build suspicion appears to be correct.I dont think this is an issue with the install script versions.
Last week I migrated away from Ubuntu managed .NET (I wanted the lastest .NET 8 SDK), and as such have installed .NET 9 via the
dotnet-install.shscript, and I do not have this Yarp issue as I originally did when using APT + BackportWhich is weird, I migrated my application to dotnet 9 before there was an Ubuntu package, following the install with the ./dotnet-install.sh (time stamp of my installation file Nov 13 07:50 dotnet-install.sh) and I’m running into the same issues the people who have the Deb package have.
Another key aspect is how we get earlier test coverage. It is possible that Canonical will offer .NET 10 previews via their PPA and/or snap. That would help a lot. I suspect that many people (like me) would happily choose that option over tarballs.
Ubuntu never provided DEB packages until 9.0 GA. So any repro using RC2 was using a Microsoft-built installation (non-source build).
Possible culprit: http://archive.ubuntu.com/ubuntu/pool/universe/d/dotnet9/aspnetcore-runtime-9.0_9.0.0-rtm-0ubuntu1~24.10.1_amd64.deb https://ubuntu.pkgs.org/24.10/ubuntu-updates-universe-amd64/aspnetcore-runtime-9.0_9.0.0-rtm-0ubuntu1~24.10.1_amd64.deb.html
This deb package has an empty Microsoft.AspNetCore.Server.HttpSys.dll and different (invalid?) commit shaw a2bc464e40415d625118f38fbb0556d1803783ff. All the other versions I’ve seen have commit shaw af22effae4069a5dfb9b0735859de48820104f5b.
Was this deb package built from source? https://github.com/dotnet/aspnetcore/blob/764eb46ced38ad1355d277263474da0758bd08fb/src/Servers/HttpSys/src/Microsoft.AspNetCore.Server.HttpSys.csproj#L36-L38