xmlrpc
xmlrpc copied to clipboard
PlatformNotSupportedException on UWP
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?
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)
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.
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.
I get this issue in netcoreapp2.0
@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.
@LordVeovis This is also a dotnet core MVC application. The csproj uses "netcoreapp2.0". Is your MVC application also using netcoreapp2.0?
@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.
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.
Interesting that RestSharp also experienced this issue: https://github.com/restsharp/RestSharp/issues/1061 - Is there a config setting I can use to disable proxy detection? (edit: sorry, I didn't see you answered this yesterday)
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;