2

我试图在我的 Mono 项目的 Web.config 中配置 System.net 节点。

我不断收到此异常:

System.Configuration.ConfigurationErrorsException
Error deserializing configuration section defaultProxy: Unrecognized attribute 'enabled'. (/usr/share/nginx/aspnet/Web.config line 1)

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Configuration.
Exception stack trace:
  at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
  at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0 
  at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0 
  at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
  at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0 
  at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0 
  at System.Net.WebRequest.GetDefaultWebProxy () [0x00000] in <filename unknown>:0 
  at System.Net.WebRequest.get_DefaultWebProxy () [0x00000] in <filename unknown>:0 
  at System.Net.GlobalProxySelection.get_Select () [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:.ctor (System.Uri)
  at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in <filename unknown>:0 
  at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.GetWebRequest (System.Uri address) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.SetupRequest (System.Uri uri) [0x00000] in <filename unknown>:0 
  at System.Net.WebClient.OpenRead (System.Uri address) [0x00000] in <filename unknown>:0 

我不知道如何让我的应用程序接受 defaultProxy 节点,并将 enabled 属性设置为 true 或使用其他一些设置。

如果我从 Web.config 中删除 System.net 节点,则使用 WebClient 的应用程序部分会超时。

4

2 回答 2

2

我相信您已经在单声道中发现了一个错误。构造DefaultProxySection函数似乎忘记将属性属性添加到集合中,因此配置阅读器不知道它们。

请注意,该enabled属性的默认设置是true您可以忽略该设置作为解决问题的方法。

不过,请在bugzilla.xamarin.com中报告错误

于 2013-09-06T17:07:25.913 回答
1

死灵术。
要解决此错误,您可以设置

System.Net.WebRequest.DefaultWebProxy 

为 NULL 或

new System.Net.WebProxy();

在你做一个 WebRequest 之前。

例子:

System.Net.WebRequest.DefaultWebProxy = null;
System.Net.WebRequest.DefaultWebProxy = new System.Net.WebProxy();


System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)
System.Net.WebRequest.Create(URL);
于 2014-11-28T08:01:09.793 回答