Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: System.Net.NetworkInformation.Ping.Send throws System.Net.NetworkInformation.PingException: An exception occurred during a Ping request. #41355

Closed
rolfbjarne opened this issue Aug 25, 2020 · 3 comments
Milestone

Comments

@rolfbjarne
Copy link
Member

Description

Repro:

var p = new Ping ();
p.Send ("localhost");

result:

<System.Net.NetworkInformation.PingException: An exception occurred during a Ping request.
 ---> System.ComponentModel.Win32Exception (2): No such file or directory
   at System.Diagnostics.Process.EnsureInitialized()
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Net.NetworkInformation.Ping.SendWithPingUtility(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
   at System.Net.NetworkInformation.Ping.SendPingCore(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
   at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
   --- End of inner exception stack trace ---
   at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
   at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
   at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer)
   at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress)
   at LinkSdk.DllImportTest.<>c__DisplayClass3_0.<LackOfCapget>b__0() in [...]/xamarin-macios/tests/linker/ios/link sdk/DllImportTest.cs:line 88

I'm not sure what the behavior/result should be (the ideal is probably that it should just work, but that would probably need a very different implementation - see also https://xamarin.github.io/bugzilla-archives/96/964/bug.html), but I don't think it should be a PingException. Maybe a PlatformNotSupportedException?

The stack trace also shows that the current code tries to launch another process. That doesn't work on any of Apple's mobile platforms. Most of the System.Diagnostics.Process class should probably just throw PlatformNotSupportedException.

Configuration

.NET 5.0.100-rc.1.20414.5
iOS BCL (microsoft.netcore.app.runtime.ios-x64/5.0.0-rc.1.20404.16)

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Aug 25, 2020
@ghost
Copy link

ghost commented Aug 25, 2020

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@wfurt
Copy link
Member

wfurt commented Aug 25, 2020

This dup of #36890 and #36941.
PNSP is reasonable to me. I don't think #36941 will get done for 5.0.

cc: @marek-safar

@marek-safar
Copy link
Contributor

Closing as duplicate of #36941.

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Aug 26, 2020
….NET.

System.Net.NetworkInformation.Ping.Send doesn't work.

Ref: dotnet/runtime#41355

Fixes this link sdk test failure:

    LinkSdk.DllImportTest
        [FAIL] LackOfCapget :
            Expected: <System.InvalidOperationException>
            But was:  <System.Net.NetworkInformation.PingException: An exception occurred during a Ping request.
                ---> System.ComponentModel.Win32Exception (2): No such file or directory
                at System.Diagnostics.Process.EnsureInitialized()
                at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
                at System.Diagnostics.Process.Start()
                at System.Net.NetworkInformation.Ping.SendWithPingUtility(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
                at System.Net.NetworkInformation.Ping.SendPingCore(IPAddress address, Byte[] buffer, Int32 timeout, PingOptions options)
                at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
                --- End of inner exception stack trace ---
                at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
                at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
                at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer)
                at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress)
                at LinkSdk.DllImportTest.<>c__DisplayClass3_0.<LackOfCapget>b__0() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/DllImportTest.cs:line 88
                at NUnit.Framework.Assert.Throws(IResolveConstraint expression, TestDelegate code, String message, Object[] args)>
                at LinkSdk.DllImportTest.LackOfCapget() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/DllImportTest.cs:line 88
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
@karelz karelz added this to the 6.0.0 milestone Jan 26, 2021
@karelz karelz removed the untriaged New issue has not been triaged by the area owner label Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants