为什么 HttpRequestException 在 VS2015 模拟器而不是模拟器

Why HttpRequestException in VS2015 Simulator but not Emulator

我有一个 WinRt 通用应用程序,并且只使用 VS2015CTP Ultimate(没有第 3 方软件)。 Phone 模拟器连接到 Azure,但 Windows 模拟器需要通过 Http 代理服务器。我不在公司防火墙内。但是,如果我使用 Fiddler 并让应用程序使用其 Http 代理服务器,则模拟器可以工作。 我根本不想使用 Fiddler,所以我的问题是,如何让模拟器在没有 Fiddler 的帮助下调用我的 Azure 移动服务?

我认为代码不会有什么不同,因为 phone 和 Windows 都一样。但是,这是代码,下面是错误。

    //In Appl.xaml, VS2015 creates this code:

public static Microsoft.WindowsAzure.MobileServices.MobileServiceClient myMobileClient = 
new Microsoft.WindowsAzure.MobileServices.MobileServiceClient(
"https://nameofmobileservice.azure-mobile.net/",
"***************************");


//I added:

private IMobileServiceTable<MyResultData> GetMyResultDataTable()
        {
            IMobileServiceTable<MyResultData> myResultDataTable = null;
            try
            {
                myResultDataTable = App.myMobileClient.GetTable<MyResultData>();
            }
            catch (System.Exception e)
            {

                System.Diagnostics.Debug.WriteLine(e.InnerException);
            }
            return myResultDataTable;
        }


//This is the call that fails in Windows simulator, but works in phone emulator:

 public async Task InsertTacticResultData(MyResultData data)
        {
            IMobileServiceTable<MyResultData> myResultDataTable = GetMyResultDataTable();
   try
            {
                await myResultDataTable.InsertAsync(data);
            }
            catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.StackTrace);
                System.Diagnostics.Debug.WriteLine(e.Message);
                System.Diagnostics.Debug.WriteLine(e.InnerException);
            }
        }

Error: An error occurred while sending the request. 'MyUniversal.Windows.exe' (CLR v4.0.30319: Immersive Application Domain): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.DLL'. System.Net.WebException: The remote name could not be resolved: 'mymobileservice.azure-mobile.net' at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) Stack trace:

A first chance exception of type 'System.Net.Http.HttpRequestException' occurred in mscorlib.dll at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.<SendRequestAsync>d__1d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<>c__DisplayClass10.<<InsertAsync>b__f>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.d__41.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<InsertAsync>d__17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.WindowsAzure.MobileServices.MobileServiceTable1.<TransformHttpException>d__38.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.WindowsAzure.MobileServices.MobileServiceTable1.<InsertAsync>d__b.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()<br> at Microsoft.WindowsAzure.MobileServices.MobileServiceTable1.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at MyUniversal.Azure.AzureHelper.d__6.MoveNext()

基本上我必须 运行:Certutil -addStore TrustedPeople 请参阅 https://msdn.microsoft.com/en-us/library/windows/desktop/jj835832(v=vs.85).aspx