【发布时间】: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.dll 和 Microsoft.ApplicationServer.Caching.Core.dll 的文件版本是 1.0.4621.0。这与我安装 WindowsAzure.Caching Nuget 包时在我的项目中引用的文件相同。这是要使用的正确文件吗?
经过 15 小时的调试,我们非常感谢您对此的任何意见。
更新:
当我将this project 发布到新Web 角色的两个实例时,我实际上已经让this project 工作了。我将开始进行该部署,看看是否能发现任何差异。
更新 2:
区别在于我的项目使用Microsoft.ApplicationServer.Caching.Client.dll和Microsoft.ApplicationServer.Caching.Core.dll的版本1.0.4621.0,而微软的项目使用1.0.4655.0。所以实际上可能是我使用的是旧版本的 SDK。出于某种原因,我的项目坚持在我发布时上传这些文件,即使我删除了它们,但如果这解决了问题,我会回复完整的答案。
【问题讨论】:
标签: c# asp.net asp.net-mvc azure azure-caching