Domanda

I've installed Windows Azure Caching 2.1.0.0 from Nuget and I configured the collection of the client library diagnostics on a worker role using Azure SDK 2.1 following the instructions in this SO answer.

Unfortunately, when I start the application in the development fabric, I obtain the following exception -- I don't understand why it is complaining about the configuration file. I've searched for this error but I found nothing relevant to my case.

Microsoft.ApplicationServer.Caching.DataCacheException was caught
ErrorCode=9004
HelpLink=http://go.microsoft.com/fwlink/?LinkId=164049
HResult=-2146233088
Message=ErrorCode<ERRCMS0004>:SubStatus<ES0001>:Configuration file
(file name:"{0}") not found.
Source=Microsoft.ApplicationServer.Caching.Core
SubStatus=-1
StackTrace:
   at Microsoft.ApplicationServer.Caching.ConfigFile.
     ThrowException(Int32 errorCode)
   at Microsoft.ApplicationServer.Caching.AzureCommon.
     MemcacheUtility.GetRoleConfigPath()
   at Microsoft.ApplicationServer.Caching.AzureCommon.
     CacheDiagnostics.ConfigureMemcacheShimCrashDumps
     (DiagnosticMonitorConfiguration diagnosticMonitorConfig)
   at Microsoft.ApplicationServer.Caching.AzureCommon.
      CacheDiagnostics.ConfigureDiagnostics
      (DiagnosticMonitorConfiguration diagnosticMonitorConfig, 
      String diagnosticsStorageAccountConfigurationSettingName)
   at Microsoft.ApplicationServer.Caching.AzureCommon.
      CacheDiagnostics.ConfigureDiagnostics(
      DiagnosticMonitorConfiguration diagnosticMonitorConfig)
È stato utile?

Soluzione

I've inspected the assembly Microsoft.ApplicationServer.Caching.AzureCommon with ILSpy and I've discovered a function in which the CacheDiagnostics.ConfigureDiagnostics searches for web.config or *.dll.config for the role -- on Azure enviroment it checks for both files, while if it detects the compute emulator it checks only for web.config. IMHO this is a bug in the library (probably not so important since Caching seems to be used primarily from web roles).

I then copied the app.config for the worker role, I've renamed it to web.config and set it to be copied on the project output -- this way I was able to call CacheDiagnostics.ConfigureDiagnostics without exceptions.

Altri suggerimenti

For me, the issue was that Web.config file was getting copied under bin/Release folder while the CacheDiagnostics.ConfigureDiagnostics was looking it under approot folder. So, I manually pasted the file there to test it locally. On cloud, the config file get copied under correct directory.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top