1

I am trying to download the content of a XML file stored at a specific web address. bellow is the code

 WebClient wc = new WebClient();
 string data=wc.DownloadString(ghxuri);
 XElement xml = XElement.Parse(data);

ghxuri is the link to download the file which has the following format http://path/xml_file. I am able to download the file by clicking the link and can also run it from my c# project. But when I am trying to execute the same function using a webgl build its throwing the following error

NullReferenceException: Object reference not set to an instance of an object.

Rethrow as WebException: An exception occurred during a WebClient request. at System.Net.WebClient.DownloadDataInternal (System.Uri address, System.Net.WebRequest& request) [0x00000] in <00000000000000000000000000000000>:0

(Filename: currently not available on il2cpp Line: -1)

I am not able to understand the nullreferenceexception reason.

gman
  • 83,286
  • 25
  • 191
  • 301

1 Answers1

0

This could be probably your WebGl doesn’t have access to internet. This is expected due to a security implications, the .Net networking will not work in WebGl. See the below link for more details and alternative. https://docs.unity3d.com/Manual/webgl-networking.html

Dharman
  • 21,838
  • 18
  • 57
  • 107