Azure Web角色抛出的web.config中无法识别的元素“autoDiscover”

时间:2012-10-31 10:18:01

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

我正在尝试在两个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-package,它将正确的条目添加到web.config中,但它看起来完全一样。

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

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

经过15个小时的调试后,对此的任何意见都将受到高度赞赏。

更新

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

更新2:

不同之处在于我的项目使用1.0.4621.0Microsoft.ApplicationServer.Caching.Client.dll的版本Microsoft.ApplicationServer.Caching.Core.dll,而Microsoft的项目使用1.0.4655.0。所以实际上我可能正在使用旧版本的SDK。出于某种原因,我的项目坚持在我发布时上传这些文件,即使我删除了它们,但如果能解决问题,我会得到一个完整的答案。

1 个答案:

答案 0 :(得分:4)

尝试将最新的 Azure SDK 升级到 1.7 SP1 1.8 Azure SDK 1.8 was just released this week。仅According to MSDN forums Azure SDK 1.7.1 + 支持role-based cachingautoDiscover

Azure SDK 1.6 2011年11月)大会版本:1.0.4617.0
Azure SDK 1.7 2012年6月)大会版本:1.0.4621.0
Azure SDK 1.7.1 2012年6月SP1 )大会版本:1.0.4655.0
Azure SDK 1.8 2012年10月)大会版本:1.0.4797.0