Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在部分信任环境中使用app.config的system.net部分?_.net_Wcf_Proxy_Code Access Security_Partial Trust - Fatal编程技术网

如何在部分信任环境中使用app.config的system.net部分?

如何在部分信任环境中使用app.config的system.net部分?,.net,wcf,proxy,code-access-security,partial-trust,.net,Wcf,Proxy,Code Access Security,Partial Trust,我使用clickonce部署了一个WCF应用程序。 它使用https连接到我的服务器,一切正常 由于以下代码,我在需要时使用默认代理: <configSections> <sectionGroup name="system.net" type="System.Net.Configuration.NetSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e

我使用clickonce部署了一个WCF应用程序。 它使用https连接到我的服务器,一切正常

由于以下代码,我在需要时使用默认代理:

  <configSections>
    <sectionGroup name="system.net" type="System.Net.Configuration.NetSectionGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="defaultProxy" type="System.Net.Configuration.DefaultProxySection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    </sectionGroup>
  </configSections>
  <system.net>
    <defaultProxy useDefaultCredentials="true"/>
  </system.net>
wshttpbinding的useDefaultWebProxy属性从一开始就设置好了,但是如果没有正确定义“system.net.defaultProxy”部分,无论是在部分信任环境还是完全信任环境中,该属性似乎都不起作用:

   <binding name="WebBinding" useDefaultWebProxy="true">


我想我可以要求我的客户更新他们的本地machine.config文件以添加所需的defaultProxy useDefaultCredentials=“true”,但这肯定不会简化部署。

我相信这是一个已知的问题,可能与私钥传输有关。此处有一个MS Connect条目:

我希望我正确地理解了这个问题。如果您的问题是这个错误造成的,那么看起来还没有解决的ETA。但是,可能存在与手动请求凭据相关的解决方法。显然,这并不理想,但在部署到生产系统之前,它可能会为您提供另一种选择

在MSDN论坛上还有其他讨论:


或者,如果在公司环境中工作,您可以尝试找到使应用程序工作所需的权限。因此,不是完全信任,而是更具体的代码访问安全策略。然后通过在企业级/用户级设置的组策略设置该策略

   <section name="defaultProxy" type="System.Net.Configuration.DefaultProxySection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
System.Net.WebProxy proxy = new WebProxy();
proxy.UseDefaultCredentials = true;
WebRequest.DefaultWebProxy = proxy;
   <binding name="WebBinding" useDefaultWebProxy="true">