无法在调试中创建DataCacheFactory实例

时间:2015-03-05 15:03:06

标签: c# caching azure

  • 我正在开发将在Windows Azure Web角色上运行的Web项目;
  • 在云端,将有2个角色实例;
  • 我正在两个角色实例之间使用共存的命名缓存(角色内缓存);
  • 在本地,我使用单个实例进行调试;
  • 在云中,缓存客户端已成功创建并且流畅地工作;
  • 在本地调试时,我无法创建DataCacheFactory的实例,因为在调用构造函数时,程序流“停止”并且不会继续执行以下语句。没有例外!

这是我正在创建Factory和缓存客户端的代码:

var cacheFactoryConfig = new DataCacheFactoryConfiguration
        {
            ChannelOpenTimeout = TimeSpan.FromMinutes(2),
            TransportProperties = {ReceiveTimeout = TimeSpan.FromSeconds(45)}
        };
        DataCacheFactory cacheFactory;
        try
        {
            cacheFactory = new DataCacheFactory(cacheFactoryConfig);// <--stops here
        }
        catch (Exception e)
        {
            Trace.WriteLine(string.Format("--> Message-> {0}; --> Stack Trace->{1}", e.Message, e.StackTrace));
            throw;
        }
cacheClient = cacheFactory.GetDefaultCache();

服务配置: Service Configuration

在web.config中缓存客户端和服务器配置 Cache client and server configuration in web.config

如果需要,我会提供任何其他信息,以便尽快解决问题。

------编辑1 ------------------

由于相关帖子Making Windows Azure Caching Work in Compute Emulator,我必须添加一些信息:

  • 操作系统 - &gt; Windows 7专业版
  • IDE - &gt; Visual Studio 2013 Ultimate Update 4
  • Windows Azure缓存包2.4.0.0
  • Windows Azure SDK版本2.4

我没有安装Windows Server AppFabric,所以我要去了!

1 个答案:

答案 0 :(得分:0)

经过几天的调查,我设法解决了这个问题并成功创建了DataCacheFactory和DataCache的实例,依此类推。该问题在以下 2个帖子

中进行了描述和解决

https://social.msdn.microsoft.com/Forums/azure/en-US/8580689a-a1a1-4db7-bba9-f42c1a90e0db/windows-azure-webrole-caching-preview-hangs-makes-the-emulator-stuck-in-deploy-loop?forum=windowsazuredevelopment

http://blog.elastacloud.com/2012/06/09/using-the-windows-azure-cache-preview-with-sdk-1-7/

我想指出,Windows事件查看器帮助了很多。在Windows Azure日志中,我发现在使用Azure模拟器启动Web角色时发生的错误。 CacheInstaller.exe引发错误 - &gt; MissingMethodExceprion,带有消息:

  

找不到方法:   “Microsoft.ApplicationServer.Caching.ClusterConfigElement