首页 > 移动平台 > 详细

OWIN 托管服务器问题:StartOptions WebApp.Start TargetInvocationException

时间:2017-12-16 10:30:39      阅读:294      评论:0      收藏:0      [点我收藏+]
我有一个与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

原文:http://www.cnblogs.com/lonelyxmas/p/8045792.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!