首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Mono中配置System.Net时的问题

在Mono中配置System.Net时的问题
EN

Stack Overflow用户
提问于 2013-09-06 10:06:05
回答 2查看 1.7K关注 0票数 2

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

我一直有这样的例外:

代码语言:javascript
复制
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 

我想不出如何让我的应用程序接受已启用属性设置为true的defaultProxy节点,或者使用其他设置。

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-06 17:07:25

我相信你在mono中发现了一个窃听器。构造函数似乎忘记将属性属性添加到集合中。,所以配置读取器不知道它们。

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

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

票数 2
EN

Stack Overflow用户

发布于 2014-11-28 08:01:09

亡灵术。

为了避开这个bug,您可以设置

代码语言:javascript
复制
System.Net.WebRequest.DefaultWebProxy 

为空或至

代码语言:javascript
复制
new System.Net.WebProxy();

在你做WebRequest之前。

示例:

代码语言:javascript
复制
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);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18655165

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档