首页 文章

为什么VS2015模拟器中的HttpRequestException而不是模拟器

提问于
浏览
0

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

我不认为代码会有所作为,因为它对手机和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);
            }
        }

错误:发送请求时发生错误 . 'MyUniversal.Windows.exe'(CLR v4.0.30319:沉浸式应用程序域):已加载'C:\ WINDOWS \ assembly \ GAC_MSIL \ Microsoft.VisualStudio.Debugger.Runtime \ 14.0.0.0__b03f5f7f11d50a3a \ Microsoft.VisualStudio.Debugger.Runtime . DLL” . System.Net.WebException:无法解析远程名称:System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult)上的System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult,TransportContext&context)中的'mymobileservice.azure-mobile.net' ar)堆栈跟踪:在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)的mscorlib.dll中发生类型'System.Net.Http.HttpRequestException'的第一次机会异常(位于Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient的System.Runtime.CompilerServices.TaskAwaiter1.GetResult()的任务任务 . <SendRequestAsync> d__1d.MoveNext()---从抛出异常的上一个位置开始的堆栈跟踪结束---在System.Runtime.Compi上System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__4.MoveNext()中的lerServices.TaskAwaiter1.GetResult()---从抛出异常的上一个位置开始的堆栈跟踪---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务位于System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)的System.Runtime.CompilerServices.TaskAwaiter1.GetResult(),位于Microsoft.WindowsAzure.MobileServices.MobileServiceTable . <> c__DisplayClass10 . << InsertAsync> b__f> d__12.MoveNext ()---从抛出异常的先前位置开始的堆栈跟踪结束---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)处 . Microsoft.WindowsAzure.MobileServices.MobileServiceTable.d__41.MoveNext()中的Runtime.CompilerServices.TaskAwaiter1.GetResult()---来自先前位置的堆栈跟踪结束,其中异常是抛出---在Microsoft.WindowsAzure.MobileServices上System.Runtime.CompilerServices.TaskAwaiter1.GetResult()的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)上的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) .MobileServiceTable . <InsertAsync> d__17.MoveNext()---抛出异常的前一个位置的堆栈跟踪结束---在System.Runtime.CompilerServices.TaskAwaiter的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处System.Runtime.CompilerServices.TaskAwaiter1.GetResult()中的.HandleNonSuccessAndDebuggerNotification(任务任务),位于Microsoft.WindowsAzure.MobileServices.MobileServiceTable1 . <TransformHttpException> d__38.MoveNext()---从先前位置抛出异常的堆栈跟踪结束 - - 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)上(任务tas) k)位于Microsoft.WindowsAzure.MobileServices.MobileServiceTable1的System.Runtime.CompilerServices.TaskAwaiter1.GetResult() . <InsertAsync> d__b.MoveNext()---从抛出异常的上一个位置开始的堆栈跟踪结束---在系统中System.Runtime.CompilerServices.TaskAwaiter.GetResult()处的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)处的.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)Microsoft.WindowsAzure.MobileServices.MobileServiceTable1.d__5.MoveNext()---从抛出异常的上一个位置开始的堆栈跟踪结束---在System.Runtime.CompilerServices上的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处位于MyUniversal.Azure.AzureHelper.d__6.MoveNext()的System.Runtime.CompilerServices.TaskAwaiter.GetResult()的.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)

1 回答

相关问题