runtime: HttpClient 4.3.2 broken on Mono
Hopefully this is the right place to report this. If not, please move and/or let me know where to report.
HttpClient
appears to be broken when running on Mono with the latest release. Consider the following:
Install-Package System.Net.Http -Version 4.3.1
using System;
using System.Net.Http;
namespace HttpClientTest
{
class Program
{
static void Main(string[] args)
{
var client = new HttpClient();
var response = client.GetAsync("https://www.microsoft.com/net").Result;
Console.WriteLine(response.StatusCode);
}
}
}
Compile with VS 2017, targeting .NET Framework 4.6.1. Run from the Windows command line:
HttpClientTest.exe
Works, no problem. Run under Mono, and also works.
mono HttpClientTest.exe
Now upgrade to 4.3.2
Update-Package System.Net.Http -Version 4.3.2
Run again. Works on .NET Framework, but under Mono, I get a MissingMethodException
.
Unhandled Exception:
System.MissingMethodException: Method 'System.Net.Logging.get_On' not found.
at System.Net.Http.HttpMessageInvoker.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x0003d] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.SendAsync (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x00049] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.Uri requestUri, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x0000c] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.Uri requestUri, System.Net.Http.HttpCompletionOption completionOption) [0x00008] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.Uri requestUri) [0x00000] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.String requestUri) [0x00008] in <09d4a140061c48849b6322067e841931>:0
at HttpClientTest.Program.Main (System.String[] args) [0x00007] in <8019b64f4f864b30ba0f2936c90cfab0>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'System.Net.Logging.get_On' not found.
at System.Net.Http.HttpMessageInvoker.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x0003d] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.SendAsync (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x00049] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.Uri requestUri, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x0000c] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.Uri requestUri, System.Net.Http.HttpCompletionOption completionOption) [0x00008] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.Uri requestUri) [0x00000] in <09d4a140061c48849b6322067e841931>:0
at System.Net.Http.HttpClient.GetAsync (System.String requestUri) [0x00008] in <09d4a140061c48849b6322067e841931>:0
at HttpClientTest.Program.Main (System.String[] args) [0x00007] in <8019b64f4f864b30ba0f2936c90cfab0>:0
In another app (which I can’t post here), I get others as well:
System.MissingFieldException: Field 'System.Net.ExceptionHelper.WebPermissionUnrestricted' not found.
System.MissingMethodException: Method 'System.Net.ServicePointManager.CloseConnectionGroups' not found.
Same results on Mono 4.8.0 or 5.0.0.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 13
- Comments: 53 (32 by maintainers)
Commits related to this issue
- Fix internal Mono bug on non-Windows platforms. Concerning: dotnet/corefx#19914 — committed to mellowagain/Titan by mellowagain 7 years ago
- Implement workaround for a Mono related issue Concerning: dotnet/corefx#19914 — committed to mellowagain/Titan by mellowagain 7 years ago
- Use System.Net.Http 4.0.0 for better mono/linux compatibility See also https://github.com/dotnet/corefx/issues/19914#issuecomment-334522527 and #13 — committed to MUnique/OpenMU by sven-n 6 years ago
- add System.Net.Http 4.3.1 for mono compatibility - see dotnet/corefx#19914 — committed to magicxor/Unspotifier by magicxor 6 years ago
- Frontend.XF.Gtk: reinstate&improve System.Net.Http crasher workaround This workaround was not working on Linux+Mono 4.6.2 on its own, we also needed the binding redirect that I'm including here (whic... — committed to diginex/gwallet by knocte 6 years ago
- Frontend.Console: bring the System.Net.Http crasher workaround This crash (reported here [1]) was being workarounded in the frontend branch, but it turns out the Console frontend (in this master bran... — committed to diginex/gwallet by knocte 6 years ago
- Remove unneeded System.Net.Http dependency See https://github.com/dotnet/corefx/issues/19914#issuecomment-529113925 — committed to nblockchain/JsonRpcSharp by ysangkok 5 years ago
- Remove unneeded System.Net.Http dependency See https://github.com/dotnet/corefx/issues/19914#issuecomment-529113925 — committed to nblockchain/JsonRpcSharp by ysangkok 5 years ago
- Remove unneeded System.Net.Http nuget dep See https://github.com/dotnet/corefx/issues/19914#issuecomment-529113925 — committed to nblockchain/JsonRpcSharp by ysangkok 5 years ago
- Backend: upgrade JsonRpcSharp version This one doesn't contain anymore the System.Net.Http dependency. See https://github.com/dotnet/corefx/issues/19914#issuecomment-529113925 — committed to nblockchain/geewallet by knocte 5 years ago
- Backend: upgrade JsonRpcSharp version This one doesn't contain anymore the System.Net.Http dependency. See https://github.com/dotnet/corefx/issues/19914#issuecomment-529113925 — committed to nblockchain/geewallet by knocte 5 years ago
- Remove System.Net.Http Nuget reference See https://github.com/dotnet/corefx/issues/19914#issuecomment-529113925 — committed to nblockchain/JsonRpcSharp by ysangkok 5 years ago
- Upgrade to NBitcoin 4.2.8, remove Http workaround - Update NBitcoin.Altcoins too (released with NBitcoin) - Remove Version attribute from PackageReferences of System.Net.Http - Remove package.config ... — committed to nblockchain/geewallet by ysangkok 5 years ago
- Remove Http workaround (&upgrade NBitcoin&JsonRpcSharp&Nethereum) - Upgrade NBitcoin&Nethereum&JsonRpcSharp to versions that don't depend on System.Net.Http - Update NBitcoin.Altcoins too (released w... — committed to nblockchain/geewallet by ysangkok 5 years ago
- Remove Http workaround (&upgrade NBitcoin&JsonRpcSharp&Nethereum) - Upgrade NBitcoin&Nethereum&JsonRpcSharp to versions that don't depend on System.Net.Http - Update NBitcoin.Altcoins too (released w... — committed to nblockchain/geewallet by ysangkok 5 years ago
- Remove Http workaround (&upgrade NBitcoin,JsonRpcSharp&Nethereum) - Upgrade NBitcoin&Nethereum&JsonRpcSharp to versions that don't depend on System.Net.Http - Update NBitcoin.Altcoins too (released w... — committed to nblockchain/geewallet by knocte 5 years ago
- Backend: upgrade HtmlAgilityPack nuget dependency The reason is that the new versions don't depend anymore on the deprecated System.Net.Http nuget package. See [1] forr more info. [1] https://github... — committed to nblockchain/geewallet by knocte 4 years ago
My workaround was to add the following AfterBuild task that removes the .NET Standard .dll:
Any updates on this issue? I’m seeing the missing method exception (System.Net.Logging.get_On) running unit tests against a .net standard 2 class library that uses HttpClient. This is using Mono 5.4.1.7. Any guidance would be greatly appreciated.
Still an issue with
Mono version 5.4.0.199
(macOS) Console apps using NetStd2 libraries.It’s super concerning that no one at Xamarin or Microsoft has provided a non-hacky workaround to this issue. Surely deleting System.Net.Http is not the final solution…
@marek-safar I’ve put the smallest repro I could come up with in this repository.
Do you still need someone to open a bug report?
Basically this is the whole code:
Program.cs
TestProj.csproj
TestProj.sln
And this is basically my system information (you can see it in more detail in my repository):
I think the proposal of not shipping any update to this package makes it easier for Mono to stay on top of things which is good. At the same time, it’d be helpful to mark this package as deprecated or something like that at nuget.org.
@marek-safar Thanks for the details.
In a perfect world, we would ship a new fixed version of this package. However, that is impossible now. The source code for the System.Net.Http NuGet package is built out of the release/2.0 branch which is now end-of-life. We no longer can even build a new System.Net.Http package out of the master branch. We no longer have the forked copy of the .NET Framework based System.Net.Http code in the master branch to build the .NET Framework targetted binary of System.Net.Http.dll.
The guidance we give developers now is to stop using the System.Net.Http NuGet package. It is not needed anymore because the System.Net.Http.dll binary already ships in the Microsoft.NETCore.App package. And for .NET Framework targeted applications, the one in the GAC is used.
We understand that some developers still use the package because it is either directly or indirectly used by the dependencies. For those cases, we have added tooling in Visual Studio to try to ignore the System.Net.Http.dll binary from that package and use the one from Microsoft.NETCore.App package or the GAC’d version on the machine. However, this solution is not perfect because for Mono based applications there is no sufficient tooling to do that redirection.
The summary is that this is not something we can fix unfortunately except by the magic of time. Over time, developers will use updated packages of things that no longer bring in the legacy and broken System.Net.Http NuGet package.
So, since this is not actionable anymore by CoreFx for this. We plan to close this issue.
Well, it’s actionable on CoreFX side by stop relying on internal framework members. On Mono we have the only workaround which does patching of every version of this published NuGet for .NET Framework but as you can expect this is not a great solution
Also having this issue. We force our net461 application to use Mono’s fallback System.Net.Http 4.0.0 from /usr/lib/mono/4.5-api by deleting the System.Net.Http that is published with the application and changing the existing record to:
in the <app_name>.exe.config after publishing for net461 (and netstandard2.0 on the side). But this is obviously not the preferred solution. Is anyone going to fix this in Mono?
Mono version used: 5.4.0.167