Closed morpheusxx closed 3 years ago
These packages are not supported on .NET 5, you should be using AspNet Core instead.
Thank you for the very quick response. I probably need to explain my environment a bit more:
The application is Windows Forms based and uses the Owin selfhosting inside the UPnP library used for client/server communication. The UPnP library can be found here as part of MediaPortal 2: https://github.com/MediaPortal/MediaPortal-2/tree/EXP_NET5/MediaPortal/Source/Core/UPnP.
you should be using AspNet Core instead.
So how could AspNet Core can be used in my case? Or are there any other .NET Core alternatives on Windows?
Unlike ASP.NET 4.x, ASP.NET Core fully supports self-host scenarios. Much of ASP.NET Core was derived from these Microsoft.Owin libraries.
Becomes something like: https://github.com/dotnet/aspnetcore/blob/b143a974a5574b9fccedbbe2389aabbfd48fdb6f/src/Hosting/samples/GenericWebHost/Program.cs#L14-L28 but change RunAsync to StartAsync since it looks like you want to start multiple servers.
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
https://github.com/aspnet/AspNetKatana/blob/1fba52940ccfa74470c75c627699baca13aadfa4/src/Microsoft.Owin.Host.HttpListener/OwinHttpListener.cs#L289
I changed this code line to:
if (IsMono || CookedPathField == null)
and it fixed my issue. I didn't find other issues yet.
I am porting a .NET Framework 4.7 application to .NET 5 which uses Microsoft.AspNet.WebApi.OwinSelfHost 5.2.7 (which depends on Microsoft.Owin.Host.HttpListener).
When running my app in VisualStudio I can see NullReferenceExceptions logged in DEBUG outputs. When using decompile feature I can see the source from accessing the 2 static fields:
https://github.com/aspnet/AspNetKatana/blob/1fba52940ccfa74470c75c627699baca13aadfa4/src/Microsoft.Owin.Host.HttpListener/OwinHttpListener.cs#L30-L31
They depend on reflection of non-public fields.
The NRE itself happens at line 226 when accessing
text = (((string)CookedPathField.GetValue(request)) ?? string.Empty);
. For mono there seems to be another approach used.Can you please review the reflection based access to the 2 fields using .NET 5?