Exception when calling CacheDiagnostics.ConfigureDiagnostics from a worker role with Caching 2.1

StackOverflow https://stackoverflow.com/questions/19166117

سؤال

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)
هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top