Internal NullReferenceException in OwinHttpListener.cs on .Net(Core) 5
See original GitHub issueI 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:
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?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Why is [Owin] throwing a null exception on new project?
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: An unhandled exception was ...
Read more >NullReferenceException Class (System)
Initializes a new instance of the NullReferenceException class with a specified error message and a reference to the inner exception that is the...
Read more >System.NullReferenceException while trying to load a view
I am trying to load DataMgmt.cshtml view by clicking on a link from my _Layout page but the page which should be loaded...
Read more >Friends Don't Let Friends Swallow NullReferenceException
ASP.NET MVC framework is swallowing NullReferenceException without you even noticing. While it might slow the page load a little bit, it is not...
Read more >Object reference not set to an instance of an object.
It simply means that some member/variable of some reference type is dereferenced by using and of its instance (non-static) members, which ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
This: https://github.com/MediaPortal/MediaPortal-2/blob/8234fb872b2f1b59338468cbd57d2127edff0388/MediaPortal/Source/Core/UPnP/Infrastructure/Dv/UPnPServer.cs#L185
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.
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.