System.ArgumentException in UWP package trying to set HttpWebRequest.UserAgent

0

i'm not an experienced Windows developers, so sorry if it could be a stupid question. I'm actually working on an UWP application for the microsoft store, and it is working when I launch it on my machine to debug, but when I create the package to release on the microsoft store, the same codebase throws an exception in this snippet, when I try to set the UserAgent:

var webRequest = WebRequest.CreateHttp(jOptions.SelectToken(DataParameters.PATH).ToString());
 webRequest.UseDefaultCredentials = true; 
 webRequest.Proxy.Credentials = CredentialCache.DefaultCredentials; 
 webRequest.Accept = “application/json”; 
 try {
    webRequest.UserAgent = “application/windows”; 
 } catch (Exception ex) {
    log.Here().Debug(“Exception occurred: ” + ex.Message); 
 }

The exceptions thrown looks like this:

Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll
System.ArgumentException
  HResult=0x80070057
  Message=The path is empty.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

I think could be something in the configuration of the package, but I need an hint at this point.

c#
windows
uwp
asked on Stack Overflow Feb 8, 2021 by Oni_01 • edited Feb 8, 2021 by Raymond Chen

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0