【问题标题】:Trouble getting Caching working inside Azure Web Sites无法在 Azure 网站中使用缓存
【发布时间】:2012-12-19 15:29:04
【问题描述】:

我正在尝试在我的 Windows Azure 网站上使用缓存。缓存是在我的一个 Worker 角色上配置的。

我是从这篇文章开始的:http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/

最初,由于缺少程序集错误,我无法让 Azure 缓存客户端 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

我希望有人能在正确的方向上帮助我。

【问题讨论】:

    标签: azure azure-web-app-service azure-caching


    【解决方案1】:

    您无法从网站访问 Windows Azure 缓存。您只能从 Web Role 或 Worker Role 访问它。

    您是否在您的网站中尝试过Windows Azure Shared Caching?这应该可以(我自己还没有在网站上尝试过)。

    【讨论】:

    • 感谢 Sandrino,我尝试使用 Windows Azure 共享缓存并使其正常工作。但是我没有使用 OutputCacheAttributes 而是直接使用了 DataCache 对象。
    • 有一个新的分布式缓存服务,可从所有 Azure 服务(网站、工作角色、Web 角色、VM 等)访问 - 目前处于预览阶段。请参阅 Scott Guthrie 的 this。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-24
    • 2013-08-04
    • 2019-06-09
    • 1970-01-01
    • 1970-01-01
    • 2021-06-16
    • 1970-01-01
    相关资源
    最近更新 更多