OWIN 託管伺服器問題:StartOptions WebApp.Start TargetInvocationException

來源:互聯網
上載者:User

標籤:localhost   execution   string   消失   服務   orm   dll   admin   cli   

我有一個與OWIN託管的伺服器有一個小問題。我試圖讓它可以訪問本網,這意味著我不得不添加一些額外的選擇:// Start OWIN host         StartOptions options = new StartOptions();        options.Urls.Add("http://localhost:4004");        //options.Urls.Add("http://127.0.0.1:4004");        //options.Urls.Add(string.Format("http://{0}:4004", Environment.MachineName));        using (WebApp.Start<Startup>(options))        {            // Create HttpCient and make a request to api/values             HttpClient client = new HttpClient();            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/text"));        }現在的問題是,如果我取消注釋第二行:options.Urls.Add("http://127.0.0.1:4004");我會得到一個錯誤:mscorlib.dll中發生未處理的類型為“System.Reflection.TargetInvocationException”的異常附加資訊:調用的目標引發了異常。

 解決方案:

 

事實上問題在於缺少管理員權限。引起了一個被拒絕的內部異常。在清單應用程式檔案中使用這個,錯誤消失了:)  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"><security>  <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />  </requestedPrivileges></security>

 

OWIN 託管伺服器問題:StartOptions WebApp.Start TargetInvocationException

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.