I want to try out the new read-through/write-behind feature of AppFabric 1.1. I implemented a provider that references some other own assemblies, according to http://msdn.microsoft.com/en-us/library/hh361698%28v=azure.10%29.aspx. All are signed and compiled for AnyCPU. I put the provider and all referenced assemblies in the GAC (see http://msdn.microsoft.com/en-us/library/hh361703(v=azure.10).aspx). Then I stopped the cache cluster and created a new cache with the read-through and write-behind options passing the full name of my provider assembly (that I got from gacutil -l).
New-Cache ReadThroughWriteBehindCache -ReadThroughEnabled true -WriteBehindEnabled true
-WriteBehindInterval 60 -ProviderType "CachingDemo.Provider, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=236fd28d53a6f1ad" -ProviderSettings @{"connectionString"="Data Source=.;Initial
Catalog=Demo;Persist Security Info=True;User
ID=sa;Password=password;MultipleActiveResultSets=True";"logFilePath"="C:\Logs\CacheProvider"}
When starting the cache cluster again I got a timeout and following error message in the event log:
AppFabric Caching service crashed with exception Microsoft.ApplicationServer.Caching.DataCacheException:
ErrorCode<ERRCMS0007>:SubStatus<ES0001>:Provider "CachingDemo.Provider, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=236fd28d53a6f1ad" instantiation failed: The given assembly name
or codebase was invalid. (Exception from HRESULT: 0x80131047) ---> System.IO.FileLoadException:
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
What could possibly be wrong? I triple-checked the assembly name. The name I passed when creating the cache is exactly the same as the one I get from gacutil -l. The assembly is AnyCPU what should work in any case. Since the assembly is not even loaded errors inside the assembly can be ruled-out.
The reason was that the provider type information was not correctly passed when creating the cache. I assumed that AppFabric would find the provider itself (by reflection). But we have to add the provider type in the ProviderType argument. Additionaly between the type and the assembly information only a comma is allowed (not a comma with a space for example):
New-Cache ReadThroughWriteBehindCache -ReadThroughEnabled true -WriteBehindEnabled true
-WriteBehindInterval 60 -ProviderType CachingDemo.Provider.Provider,CachingDemo.Provider,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=236fd28d53a6f1ad"
-ProviderSettings @{"connectionString"="Data Source=.;
Initial Catalog=Demo;Persist Security Info=True;
User ID=sa;Password=password;MultipleActiveResultSets=True";
"logFilePath"="C:\Logs\CacheProvider"}
User contributions licensed under CC BY-SA 3.0