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

PlatformNotSupportedException on UWP #4

Open
anders9ustafsson opened this issue Jul 23, 2018 · 10 comments
Open

PlatformNotSupportedException on UWP #4

anders9ustafsson opened this issue Jul 23, 2018 · 10 comments
Labels
bug Something isn't working

Comments

@anders9ustafsson
Copy link

When trying out a very simple client example on Universal Windows Platform, UWP,

[XmlRpcUrl("https://xxx/UserInterfaceServlet/")]
public interface IService : IXmlRpcProxy
{
    [XmlRpcMethod("userInterface.execute")]
    string Execute(Hashtable parameters);
}

var proxy = XmlRpcProxyGen.Create<IService>();
var response = proxy.Execute(new Hashtable());

I get a PlatformNotSupportedException with the following stack trace:

at System.Net.SystemWebProxy.GetProxy(Uri destination)
at System.Net.ServicePointManager.ProxyAddressIfNecessary(Uri& address, IWebProxy proxy)
at System.Net.ServicePointManager.FindServicePoint(Uri address, IWebProxy proxy)
at System.Net.HttpWebRequest.get_ServicePoint()
at CookComputing.XmlRpc.XmlRpcClientProtocol.SetProperties(WebRequest webReq)
at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke(Object clientObj, MethodInfo mi, Object[] parameters)
at XmlRpcProxy552bc3ad-efd6-47ae-8c4e-83a207a7aaf7.Execute(Hashtable parameters)
at XmlRpcWebServicesTests.Testing() in .\XmlRpcWebServicesTests.cs:line 13

Any known workarounds to this issue?

@LordVeovis
Copy link
Owner

I have neither experience with UWP nor a workaround to propose you. However since 1.0.3, the library targets .netstandard20, which include UWP 10.0.16299.
Can you confirm the version of:

  • UWP
  • Kveer.XmlRPC to be exactly 1.0.3 (or 1.0.5+ in a couple of days)

PS: don't try the v1.0.4 as it contains a very stupid bug of mine that make the library completely useless (see #2)

@LordVeovis LordVeovis added the help wanted Extra attention is needed label Jul 23, 2018
@anders9ustafsson
Copy link
Author

I have also tested my own .NET Standard 2.0 fork of xml-rpc.net with the same outcome, so I am pretty certain the issue is with UWP missing the implementation of SystemWebProxy.GetProxy.

Unfortunately you occasionally run into these issues with UWP, where peripheral functionality has not been implemented for whatever reason. I have not examined xml-rpc.net yet to tell whether there are alternative ways to accomplish the same thing, but if you have more experience with it I am happy for any suggestion you may have.

BTW, I am using UWP Build 17134. I was using Kveer.XmlRPC 1.0.4, but I doubt it that any other version would have resolved this particular issue anyway.

@anders9ustafsson
Copy link
Author

anders9ustafsson commented Jul 24, 2018

One more thing: if 1.0.4 is broken, you might consider hiding it on NuGet. You cannot delete it from NuGet, but you can hide it so that newcomers don't pick it by accident when picking the Kveer.XmlRPC package for the first time.

@lorddev
Copy link
Contributor

lorddev commented Jan 3, 2019

I get this issue in netcoreapp2.0

@LordVeovis
Copy link
Owner

@lorddev can you elaborate ? netcoreapp2.0 is just an interface and not an implementation.

As said previously, I do not use UWP and from the stack trace, it is unfortunately more than likely that the issue is, like the Exception imply that the implementation (here UWP) is missing a feature. So I cannot offer support for that.

You can probably hack on CookComputing.XmlRpc.XmlRpcClientProtocol.SetProperties to disable the call to System.Net.HttpWebRequest.get_ServicePoint which will lead to the exception.

If nicely done (that is without disabling the http proxy support for other platform), I could merge that.

I'm using this library on a .netcore mvc application without issue.

@lorddev
Copy link
Contributor

lorddev commented Jan 7, 2019

@LordVeovis This is also a dotnet core MVC application. The csproj uses "netcoreapp2.0". Is your MVC application also using netcoreapp2.0?

@anders9ustafsson
Copy link
Author

@lorddev I can confirm that the PlatformNotSupportedException is present in a .NET Core 2.0 (console) application. However, with .NET Core 2.1 the issue is resolved. If possible, I recommend you upgrade to .NET Core 2.1.

@LordVeovis
Copy link
Owner

LordVeovis commented Jan 10, 2019

You both have a valid point, and thank you for your precise report.

Thats remind me of a hack I have completely forgotten.
My webapp is targeting .netcore20 to be running as a docker container.

The hack:

WebRequest.DefaultWebProxy = null;
var rpc = XmlRpcProxyGen.Create<IRtorrent>();

I'm sorry I didn't think of that earlier. While not solving the problem directly from the library, this will prevent the present case resulting on a PlatformNotSUpportedException.
Naturally, it does not work if you are using an http proxy, which is the feature not present on .netcore20 and uwp yet.

You just have to put the first line once, but absolutely before the creation of a xmlrpc proxy.

@LordVeovis LordVeovis added bug Something isn't working and removed help wanted Extra attention is needed labels Jan 10, 2019
@lorddev
Copy link
Contributor

lorddev commented Jan 11, 2019

Interesting that RestSharp also experienced this issue: restsharp/RestSharp#1061 - Is there a config setting I can use to disable proxy detection? (edit: sorry, I didn't see you answered this yesterday)

@LordVeovis
Copy link
Owner

Interesting that RestSharp also experienced this issue: restsharp/RestSharp#1061 - Is there a config setting I can use to disable proxy detection?

If the stack trace is the same as here, just use this before calling RestSharp.

WebRequest.DefaultWebProxy = null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants