Skip to content

.NET MAUI iOS "Operation not supported on this platform" #1918

Closed

Description

@vladsava87

Describe the bug
In a .NET MAUI project running on iOS, creating an new instance of RestClient, throws an "Operation not supported on this platform" exception.
Android works as expected.

To Reproduce
Create new .NET MAUI project, add RestSharp nuget and create new RestClient object.
Run project on iOS configuration.

Expected behavior
Create a new instance of RestClient

Stack trace
at System.Net.Http.NSUrlSessionHandler.set_Proxy(IWebProxy value)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of stack trace from previous location ---
at System.Net.Http.HttpClientHandler.InvokeNativeHandlerMethod(String name, Object[] parameters)
at System.Net.Http.HttpClientHandler.SetProxy(IWebProxy value)
at System.Net.Http.HttpClientHandler.set_Proxy(IWebProxy value)
at RestSharp.RestClient.ConfigureHttpMessageHandler(HttpClientHandler handler)
at RestSharp.RestClient..ctor(RestClientOptions options, Action`1 configureDefaultHeaders)
at RestSharp.RestClient..ctor()
at MauiAuth0App.MauiProgram.CreateMauiApp() in /Users/vladsteer73/Work/R&D/dotnet-maui-auth0-app-main/MauiProgram.cs:line 32

Desktop (please complete the following information):

  • OS: macOS
  • .NET 6
  • Version 6.0.400

image

Activity

  1. FirewizzNL commented on Sep 7, 2022

    @FirewizzNL

    Got the same issue

  2. vadd98 commented on Sep 7, 2022

    @vadd98

    I have the same issue and I had to move to use the HttpClient in System.Net.Http

  3. FirewizzNL commented on Sep 8, 2022

    @FirewizzNL

    Thanks, I will move to too. After a bit of searching it looks like this has been like this for ages

  4. SebastianGrief commented on Sep 8, 2022

    @SebastianGrief
    Contributor

    Setting the handler.Proxy in RestClient.cs:142 is causing that because custom proxies are not allowed in NSUrlSessionHandler:625-628

    So adding if(handler.SupportsProxy) handler.Proxy = Options.Proxy; in RestClient fixes the instance creation.
    I've not yet tested that any further tho. Edit: Everything is working fine for me with that one line changed.

  5. dennisarriola commented on Sep 19, 2022

    @dennisarriola

    Hello, I am experiencing this too. Hope this will be supported by RestSharp in their next release.
    I'm using 108.0.1 by the way.

  6. alexeyzimarev commented on Sep 19, 2022

    @alexeyzimarev
    Member

    Thanks, I will move to too. After a bit of searching it looks like this has been like this for ages

    For's been there for ages is irrelevant as RestSharp doesn't work as it used to.

    Thanks @SebastianGrief for the tip, mind opening a PR?

  7. dennisarriola commented on Sep 23, 2022

    @dennisarriola

    Hello,

    Is the fix included in v108.0.2 release?
    I am using the library from nuget.

  8. dennisarriola commented on Sep 26, 2022

    @dennisarriola

    Hello @alexeyzimarev

    I tried v108.0.2 and it throws Timeout error.
    Here's the exact error message, "The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing."
    I'm not sure if I missed something, but it works perfectly fine in Android and in Windows platforms. This only happens in iOs platform.

    Do you have any idea on how to resolve this?

    Thank you very much.

  9. dennisarriola commented on Sep 29, 2022

    @dennisarriola

    Hello,

    We would like to follow-up, if .NET Maui iOS platform is already supported by this fix?
    Thank you.

  10. alexeyzimarev commented on Sep 29, 2022

    @alexeyzimarev
    Member

    Screenshot 2022-09-29 at 13 19 44

  11. alexeyzimarev commented on Sep 29, 2022

    @alexeyzimarev
    Member

    The fix resolved the "Operation not supported on this platform" issue with the proxy. That's what issue was about, and that's why it's closed.

  12. dennisarriola commented on Sep 30, 2022

    @dennisarriola

    I see. Thank you for reply @alexeyzimarev.
    Guess .NET Maui iOs platform is still not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions