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



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

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

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 在任何情况下都应该工作。由于装配体甚至没有加载,因此可以排除装配体内部的错误。

原因是创建缓存时未正确传递提供程序类型信息。我假设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:LogsCacheProvider"}

最新更新