We’re using HttpWebRequest to log users into a server, and our login system is working fine on the other platforms we’re targeting: Standalone and iOS (IL2CPP). It’s hard to tell exactly where the error is occuring, but it seems to happen when we call webRequest.BeginGetRequestStream(asyncCallback, webRequest);
This looks like an internal first-chance exception that is happening inside “gethostbyname” function, which is part of windows networking API. When you get the exception, there should be a pop up with a checkbox saying “break when this exception type is thrown” (or something similar to that). Uncheck that checkbox, and click continue. It will not bother you again.
You might be wondering why this is happening. By default, Visual Studio is configured to break on any C++ exceptions, even if they’re caught. Something like this:
try
{
throw 2;
}
catch (...)
{
}
would cause the same issue, even though it’s harmless (the exception is caught).
When I disable the “break when this exception type is thrown” the UWP app still isn’t receiving responses from the server. I’m hesitant to think that it’s an issue with the server or the requests because we’re able to log in on other platforms.
I made a small repro project, and am still seeing the error on UWP, but not on other platforms. I added this script to a game object in an empty scene:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net;
using System.IO;
using System.Text;
using System;
public class WebReqTester : MonoBehaviour
{
private string txt = "";
// Use this for initialization
void Start()
{
HttpWebRequest request = (HttpWebRequest)global::System.Net.WebRequest.Create("http://www.google.com/");
request.Method = "GET";
WebResponse response = null;
try
{
Debug.Log("Performing GetResponse()");
response = request.GetResponse();
}
catch (Exception e)
{
Debug.LogFormat("Error with GetResponse:\n{0}", e);
response = null;
}
if (response != null)
{
Stream stream = response.GetResponseStream();
StreamReader sr = new StreamReader(stream, Encoding.GetEncoding("UTF-8"));
txt = sr.ReadToEnd();
sr.Close();
stream.Close();
}
Debug.LogFormat("Response from server:\n{0}", txt);
}
}
This works fine in editor, but when built with IL2CPP for UWP, the an exception gets printed out:
Did you enable networking capability in the manifest/player settings?
EDIT: your sample code seems to work here on 5.6.1f1. If I disable internet capability in the manifest, I get the same name resolution failure as you did.