【问题标题】:Unrecognized element 'autoDiscover' in web.config thrown by Azure Web RoleAzure Web Role 引发的 web.config 中无法识别的元素“autoDiscover”
【发布时间】:2012-10-20 18:39:51
【问题描述】:

我正在尝试在两个 Web 角色实例上运行的同位缓存上使用 Session State Provider for Windows Azure Caching。我有一个 ASP.NET MVC4 项目。我按照Microsofts guide 进行了设置,并多次查看,但结果相同。当我发布到 Azure 时,我在每个页面上都得到一个 YSOD。

我浏览了我的 Azure 实例上的日志,发现可能导致此问题的异常:

Event code: 3008 
Event message: A configuration error has occurred. 

...

Exception information: 
    Exception type: DataCacheException 
    Exception message: ErrorCode<ERRCMC0003>:SubStatus<ES0001>:Error in client configuration file.
   at Microsoft.ApplicationServer.Caching.ConfigFile.ThrowException(Int32 errorCode, Exception e)
   at Microsoft.ApplicationServer.Caching.ClientConfigReader.Init(String path)
   at Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration..cctor()

Unrecognized element 'autoDiscover'. (E:\sitesroot\0\web.config line 20)
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at Microsoft.ApplicationServer.Caching.ClientConfigReader.Init(String path)

我意识到这与我的 web.config 和本节有关:

<dataCacheClients> 
  <tracing sinkType="DiagnosticSink" traceLevel="Error" /> 
  <dataCacheClient name="default"> 
    <autoDiscover isEnabled="true"/> 
  </dataCacheClient> 
</dataCacheClients>

但该部分直接取自 Microsoft 指南。我还尝试卸载并重新安装 WindowsAzure.Caching Nuget 包,它将正确的条目添加到 web.config,但它看起来也完全相同。

我在 MSDN 上找到了 this discussion 关于看起来相同的问题,但我启动了一个新的 Azure Web 角色,所以我看不出它应该与 GAC 和旧版本的SDK 在这种情况下,还是我错过了什么?

查看已部署站点的 bin 文件夹,在我的 Azure 实例上,我看到我的 Microsoft.ApplicationServer.Caching.Client.dllMicrosoft.ApplicationServer.Caching.Core.dll 的文件版本是 1.0.4621.0。这与我安装 WindowsAzure.Caching Nuget 包时在我的项目中引用的文件相同。这是要使用的正确文件吗?

经过 15 小时的调试,我们非常感谢您对此的任何意见。

更新:

当我将this project 发布到新Web 角色的两个实例时,我实际上已经让this project 工作了。我将开始进行该部署,看看是否能发现任何差异。

更新 2:

区别在于我的项目使用Microsoft.ApplicationServer.Caching.Client.dllMicrosoft.ApplicationServer.Caching.Core.dll的版本1.0.4621.0,而微软的项目使用1.0.4655.0。所以实际上可能是我使用的是旧版本的 SDK。出于某种原因,我的项目坚持在我发布时上传这些文件,即使我删除了它们,但如果这解决了问题,我会回复完整的答案。

【问题讨论】:

    标签: c# asp.net asp.net-mvc azure azure-caching


    【解决方案1】:

    尝试将最新的 Azure SDK 升级到 1.7 SP11.8Azure SDK 1.8 was just released this weekAccording to MSDN forumsautoDiscover 仅在 Azure SDK 1.7.1+ 中支持role-based caching

    Azure SDK 1.62011 年 11 月)汇编版本:1.0.4617.0
    Azure SDK 1.72012 年 6 月) 程序集版本:1.0.4621.0
    Azure SDK 1.7.12012 年 6 月 SP1)程序集版本:1.0.4655.0
    Azure SDK 1.8 2012 年 10 月)汇编版本:1.0.4797.0

    【讨论】:

    • 谢谢!正如你所建议的,我通过升级到 1.8 解决了这个异常。不幸的是,那个版本会导致另一个异常,但我会将它作为另一个问题一起发布,以防我无法解决它。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-08-17
    • 1970-01-01
    • 2019-07-03
    • 2011-02-11
    • 1970-01-01
    • 2013-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多