在Azure Web Sites中无法实现缓存,遇到问题

6
我正在尝试在我的Windows Azure网站上启用缓存。缓存配置在我的一个工作角色中。
我使用了这篇文章来入门:http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/ 最初,我遇到了Azure Cache Client dll无法正常工作的问题,因为缺少程序集错误。
Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'msshrtmi, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

虽然我通过这篇文章解决了问题:http://www.thedailyparker.com/PermaLink,guid,0be6425e-b509-4122-af01-7086ce2f811e.aspx

但是接下来我遇到了一个SEHException,听起来像是一个配置问题。虽然我不知道我缺少了什么。 异常详情:

[SEHException (0x80004005): External component has thrown an exception.]
   RdGetApplicationConfigurationSetting(UInt16* , UInt16** ) +0
   RoleEnvironmentGetConfigurationSettingValueW(UInt16* pszName, UInt16* pszDest, UInt32 cchDest, UInt32* pcchRequiredDestSize) +47
   Microsoft.WindowsAzure.ServiceRuntime.Internal.InteropRoleManager.GetConfigurationSetting(String name, String& ret) +91
   Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName) +54
   Microsoft.ApplicationServer.Caching.AzureCommon.TopologyHelper.TryGetServiceConfigurationSetting(String value, String& result) +40
   Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsUtility.GetDiagnosticLevel(String propertyName) +47
   Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsUtility.GetClientLogLevel() +20
   Microsoft.ApplicationServer.Caching.AzureClientHelper.RoleUtility.ReadClientLogLevel() +5
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +108
   Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration.Initialize(String clientName) +205
   Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFactoryConfiguration(String dataCacheClientName) +77
   Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.CreateInternalProvider(IHttpRuntime httpRuntime, OutputCacheInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +28
   Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.GetInternalProvider() +148
   Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.Get(String key) +11
   System.Web.Caching.OutputCache.Get(String key) +56
   System.Web.Caching.OutputCacheModule.OnEnter(Object source, EventArgs eventArgs) +9717054
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

我希望有人能够指导我正确的方向。

这段内容与IT技术无关。
1个回答

6

您无法从网站中访问Windows Azure缓存,只能从Web角色或工作角色中访问。

您是否尝试在网站中使用Windows Azure共享缓存?这应该可以(我自己没有在网站中尝试过)。


谢谢Sandrino,我尝试使用Windows Azure共享缓存并使其工作。但是我没有使用OutputCacheAttributes,而是直接使用了DataCache对象。 - Mark Monster
1
有一个新的分布式缓存服务,可从所有Azure服务(Web Sites、Worker Role、Web role、VM等)访问 - 目前处于预览状态。请参见Scott Guthrie的此文 - seldary

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接