Forum Xamarin.iOS

WatchOS, RestSharp System.PlatformNotSupportedException ?

axaaxa Member ✭✭✭

Heres the lowdown

  • Xamarin iOS.Native, WatchOS project (extension proj to be precise)
  • Using a shared project to consume a RESTful service.
  • Shared project using RestSharp package to consume the service (which in turn uses HttpWebRequest I believe)
  • fwiw Shared project works fine in Android WearOS project, (which is why I made it a shared project)

I messed around with the iOS project properties, trying to set "iOS Build" > "HttpClient Implementation" to each:

  • NSURLSession(iOS7+)
  • CFNetwork (iOS 6+)
    -Managed (Default)

But regardless I get this exception:

{System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Net.WebProxy.CreateDefaultProxy () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
at System.Net.Configuration.DefaultProxySectionInternal.GetSection () [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
at System.Net.WebRequest.get_InternalDefaultWebProxy () [0x00022] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
at System.Net.WebRequest.get_DefaultWebProxy () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/
at RestSharp.RestClient.ConfigureHttp (RestSharp.IRestRequest request) [0x005c2] in <4b0c1fc6e5a94482990701acc6dec8b3>:0
at RestSharp.RestClient.Execute (RestSharp.IRestRequest request, System.String httpMethod, System.Func`3[T1,T2,TResult] getResponse) [0x00011] in <4b0c1fc6e5a94482990701acc6dec8b3>:0 }

It seems to be hinting at a Proxy problem but I'm not doing anything with proxies that I know of anyway...
Debugging this has proved to be over head so any help I could get tracking it down would be really appreciated.



  • axaaxa Member ✭✭✭
    Stiles me that I should have included that the exception is thrown when I attempted to make an API request and specifically when issuing an ExecuteTaskAsync method. But that probably isn't much help.

    I'm quite desperate for help, how about just from some one with experience and advice on tracking down System.PlatformNotSupportedException exceptions?
  • axaaxa Member ✭✭✭
    edited December 2018
    I came across this post:
    That suggests System.Net.WebProxy is not available in a PCL, but I'm using a shared project to house my REST consuming library.... That can't be it, can it?
    How would I check if WatchOS is missing something like this?

    Perhaps I should take it out of a shared library, put it in a .net standard 2.0 project, which I believe RestSharp supports, and see it that helps...
  • axaaxa Member ✭✭✭

    so after some digging it appears to me that I can't even use WebSocket on watchos??? so I've dumped RestSharp in favor of ModernHttpClient... hope that works...

Sign In or Register to comment.