2011-12-20 5 views
0

私はAppFabricでキャッシュを使用するAzureワーカーロールを持っています。クラウドのみAzureでクライアントDataCacheをプログラムで作成できません

クラウド内のキャッシュを指すローカル(Win7x64、VS2010)で実行すると、正常に動作します。

私は(再び同じキャッシュを指して)クラウドに同じパッケージを展開するとき、それは次の例外を生成します。このコード行があるとき

Message:   The type initializer for 'Microsoft.ApplicationServer.Caching.DataCacheClientLogManager' threw an exception. 
Exception Type: TypeInitializationException 
StackTrace:  Microsoft.ApplicationServer.Caching.DataCacheClientLogManager.Initialize(DataCacheLogSink logSink) 
       at Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration.Initialize(String clientName) 
       at CommunicationRole.CacheUtil.GetCache() 

は、これが起こっている、コードを見ましたヒット:

Dim configuration As New DataCacheFactoryConfiguration() 

この行がヒットした後は何も実行されません。私が言ったように、ローカルとクラウド間の設定は同じです。私は、キャッシュとそれへのアクセスが良いと信じるように、Webデプロイメントでセッション状態プロバイダとしての資格情報を持つキャッシュを使用します。

私のビルドマシンは、November 2011 release of the Azure SDKAzure AppFabric SDK 1.5がインストールされています。次のように

キャッシュを取得する方法は次のとおりです。

Imports System.IO 
Imports Microsoft.WindowsAzure 
Imports Microsoft.WindowsAzure.ServiceRuntime 
Imports Microsoft.WindowsAzure.StorageClient 
Imports Microsoft.ApplicationServer.Caching 
Imports System.Security 

Public Class CacheUtil 

    Private Shared _factory As DataCacheFactory = Nothing 
    Private Shared _cache As DataCache = Nothing 

    Public Shared Function GetCache() As DataCache 


      If _cache IsNot Nothing Then 
       Return _cache 
      End If 

      '------------------------- 
      ' Configure Cache Client 
      '------------------------- 

      'Define Array for 1 Cache Host 
      Dim servers As New List(Of DataCacheServerEndpoint)() 


      'Specify Cache Host Details 
      ' Parameter 1 = host name 
      ' Parameter 2 = cache port number 
      servers.Add(New DataCacheServerEndpoint(RoleEnvironment.GetConfigurationSettingValue("hostName"), Int32.Parse(RoleEnvironment.GetConfigurationSettingValue("cachePort")))) 

      ' Setup secure key 
      Dim strACSKey As String = RoleEnvironment.GetConfigurationSettingValue("authorisationToken") 
      Dim secureACSKey As New SecureString 
      For Each a As Char In strACSKey 
       secureACSKey.AppendChar(a) 
      Next 
      secureACSKey.MakeReadOnly() 
      Dim factorySecurity As New DataCacheSecurity(secureACSKey) 

      'Create cache configuration 
      Dim configuration As New DataCacheFactoryConfiguration() 

      configuration.Servers = servers 
      configuration.SecurityProperties = factorySecurity 

      'Disable tracing to avoid informational/verbose messages on the web page 
      DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off) 

      'Pass configuration settings to cacheFactory constructor 
      _factory = New DataCacheFactory(configuration) 

      'Get reference to named cache called "default" 
      _cache = _factory.GetCache(RoleEnvironment.GetConfigurationSettingValue("cacheName")) 


     Return _cache 
    End Function 

    Public Shared Sub Dispose() 
     If _factory IsNot Nothing Then 
      _factory.Dispose() 
     End If 
    End Sub 

End Class 

答えて

1

SDKの2011年11月のリリースでは、AppFabricのの.dll(バージョン1.6)が含まれていないので、あなたは、もはや独立したSDKは、AppFabricのためだけにインストールする必要があります。私はあなたのプロジェクトに行き、キャッシング.dllへの参照を削除して、それらをWindows \ Azure SDK \ v1.6 \ Cache \ refの下にあるものを指すように追加してみます。

私はビルドサーバーが.dllを参照するのを混乱させる可能性があることが判明しました。

+1

ありがとう - これは、コピーローカルがfalseに設定されているDLLを確認するのに役立ちました。最後に、私はMicrosoft.WindowsFabric.CommonとMicrosoft.WindowsFabric.Data.Commonを "ローカルコピー"設定をtrueに設定し、すべての作業を開始します。 – alergy

+0

Azure OSの現在のアセンブリとプロジェクトファイルを比較するユーティリティです。これは将来の命を救う人だと思う:[リンク](http://gacviewer.cloudapp.net) – alergy

+1

@alergy私はこの同じエラーを受けていましたが、青空を扱っていませんでした。あなたのコメントを読んだ後、私はビンにそれらのDLLを落とし、すべてがうまくいった!ありがとう:) – Joshua

関連する問題