Mono: Awaiting DelegatingHandler base.SendAsync throws a Null exception

Created on 10 Apr 2018  路  4Comments  路  Source: mono/mono

Steps to Reproduce

InnerHandler is null

  1. Create a class that inherits from DelegatingHandler
  2. Override the SendAsync method
  3. Inside the overrided method, await for base.SendAsync
  4. It throws an exception

    https://github.com/TorontoMobileDevelopers/HttpTracer/blob/master/src/HttpTracer/HttpTracerHandler.cs#L47

screen shot 2018-04-09 at 9 55 59 pm

Current Behavior

I can't await the base method, it is throwing an exception.

Expected Behavior

I'm expecting to be able to await the base method and be able to work with the response

On which platforms did you notice this

[x] macOS
[ ] Linux
[x] Windows

Version Used:

Mono Debugging for Visual Studio 4.9.11-pre (71eb098)
Support for debugging Mono processes with Visual Studio.

Stacktrace

 at System.Net.Http.DelegatingHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.9.1.24/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/DelegatingHandler.cs:76 
  at HttpTracer.HttpTracerHandler.<>n__0 (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x1325e2950 + 0x0007a> in <45fa7ebf3ce14963aa21f1f83ec864d3>:0 
  at HttpTracer.HttpTracerHandler+<SendAsync>d__1.MoveNext () [0x0009a] in C:\HttpTracer\src\HttpTracer\HttpTracerHandler.cs:47 
System.Net.Http good first issue os-windows

All 4 comments

Although this is not ideal, it's inline with .net behaviour

Oh, I was wrong .net actually throws here

throw new InvalidOperationException(SR.net_http_handler_not_assigned);

I was able to get it going by initiating the InnerHandler but I still think that mono throwing a null exception is not a good thing.

Mono uses corefx source code for DelegatingHandler class on macOS and Unix so it throws proper exception there. On Windows Mono uses own implementation which could be updated with InvalidOperationException.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

triztian picture triztian  路  4Comments

JustArchi picture JustArchi  路  4Comments

imranazad picture imranazad  路  3Comments

alxchk picture alxchk  路  4Comments

equalent picture equalent  路  4Comments