Skip to content

System.Net.NetworkInformation.Ping does not work in MauiApp on iOS Device, .net 7 #80253

Closed
@skima74

Description

@skima74

Description

Cant seem to use the System.Net.NetworkInformation.Ping class on an ios device.
The deployment works fine on windows.
On the iOS device the code reports the following error at run time:

2022-12-30 10:53:41.989 Xamarin.PreBuilt.iOS[1496:228454] Could not resolve assembly System.Net.Ping.resources, Version=7.0.0.0, Culture=en-AU, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/C25117AA-26EE-424F-89D6-C22B5D0F2901/Documents/MauiTestPingApp.content/System.Net.Ping.resources.dll' or one of its dependencies.

2022-12-30 10:53:41.991 Xamarin.PreBuilt.iOS[1496:228454] Could not resolve assembly System.Net.Ping.resources, Version=7.0.0.0, Culture=en, PublicKeyToken=null. Details: Could not load file or assembly '/var/mobile/Containers/Data/Application/C25117AA-26EE-424F-89D6-C22B5D0F2901/Documents/MauiTestPingApp.content/System.Net.Ping.resources.dll' or one of its dependencies.

[0:] An error occurred: 'No route to host'. Callstack: '   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, Boolean disconnectOnFailure, String callerName)
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, SocketFlags socketFlags, EndPoint remoteEP)
   at System.Net.NetworkInformation.Ping.SendIcmpEchoRequestOverRawSocket(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.Send(IPAddress address, Int32 timeout, Byte[] buffer, PingOptions options)'

Steps to Reproduce

Created a standard new MauiApp, added a button and entry to test the Ping functionality.
The code from the Ping test is taken directly from the MS docs :
https://learn.microsoft.com/en-us/dotnet/api/system.net.networkinformation.ping?view=net-7.0

Link to public reproduction project repository

skima74/MauiExperiments/MauiTestPingApp

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 16 physical device, did not other mobile platforms

Did you find any workaround?

Nope.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Netneeds-author-actionAn issue or pull request that requires more info or actions from the author.os-iosApple iOS

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions