AppFabric:缓存主机无法加载提供程序程序集以进行读写和后写

时间:2013-11-16 21:04:06

标签: caching appfabric-cache

我想尝试AppFabric 1.1的新的直读/后写功能。根据{{​​3}},我实现了一个引用其他自己的程序集的提供程序。所有都是为AnyCPU签名和编译的。我将提供程序和所有引用的程序集放在GAC中(请参阅http://msdn.microsoft.com/en-us/library/hh361698%28v=azure.10%29.aspx)。然后我停止了缓存集群并创建了一个新的缓存,其中包含read-through和write-behind选项,传递了我的提供程序程序集的全名(我从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"}

再次启动缓存群集时,我收到超时并在事件日志中显示以下错误消息:

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)

可能出现什么问题?我三重检查了程序集名称。我在创建缓存时传递的名称与从gacutil -l获得的名称完全相同。程序集是AnyCPU,无论如何都应该有效。由于装配不均匀,装配体内的错误可以被排除。

1 个答案:

答案 0 :(得分:0)

原因是创建缓存时未正确传递提供程序类型信息。我假设AppFabric会找到提供者本身(通过反思)。但我们必须在ProviderType参数中添加提供程序类型。除了类型和汇编信息之外,只允许使用逗号(例如,不是带空格的逗号):

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"}