问题
I'm trying to build and run WindowsServerAppFabricSamples CacheAPISample application. I had to install Microsoft.WindowsAzure.Caching version 2.3.1.0 from nuget to build. My config is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere"/>
<section name="cacheDiagnostics" type="Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsConfigurationSection, Microsoft.ApplicationServer.Caching.AzureCommon" allowLocation="true" allowDefinition="Everywhere"/>
</configSections>
<dataCacheClients>
<dataCacheClient name="default" />
</dataCacheClients>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
When I run the application I get exception with message:
Check the client version. It should be within the allowed version range on the server. If necessary, upgrade the client to the allowed version.
Exception trace:
Microsoft.ApplicationServer.Caching.DataCacheException was unhandled
HelpLink=http://go.microsoft.com/fwlink/?LinkId=164049
HResult=-2146233088
Message=ErrorCode<ERRCA0019>:SubStatus<ES0001>:Check the client version. It should be within the allowed version range on the server. If necessary, upgrade the client to the allowed version.
Source=Microsoft.ApplicationServer.Caching.Client
ErrorCode=19
SubStatus=-1
StackTrace:
at Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination)
at Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination)
at Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable`1 servers, RequestBody request, Func`3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy)
at Microsoft.ApplicationServer.Caching.WcfClientProtocol.Initialize(IEnumerable`1 servers)
at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate)
at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName)
at CacheAPISample.Program.PrepareClient() in c:\Programming\WindowsServerAppFabricSamples\Samples\CS\Cache\CacheAPISample\CacheAPISample\Program.cs:line 617
at CacheAPISample.Program.Main(String[] args) in c:\Programming\WindowsServerAppFabricSamples\Samples\CS\Cache\CacheAPISample\CacheAPISample\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Responsible code part is:
private void PrepareClient()
{
List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>(1);
servers.Add(new DataCacheServerEndpoint("localhost", 22233));
DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration();
configuration.Servers = servers;
configuration.LocalCacheProperties = new DataCacheLocalCacheProperties();
DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off);
myCacheFactory = new DataCacheFactory(configuration);
// Breaks after this comment.
myDefaultCache = myCacheFactory.GetCache("default");
}
In administration Windows PowerShell I have run get-cachehost
command. Here's what I got:
HostName : CachePort Service Name Service Status Version Info
-------------------- ------------ -------------- ------------
KOKICA:22233 AppFabricCachingService UP 3 [3,3][1,3]
Both server and client application are running on the same Windows 8.1 machine. AppFabric 1.1 is installed. Cache dependencies
Microsoft.ApplicationServer.Caching.Client.dll, Microsoft.ApplicationServer.Caching.Core
are in
C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\v2.2\ref\Caching
File version is 1.0.5137.0. Any attempts to help me resolve this issue will be appreciated.
回答1:
The libraries you referred are for Azure Cache, whereas what you are looking for is client libraries for onPremise Appfabric for windows server.
If you have installed Microsoft Appfabric 1.1 for windows server from here:http://www.microsoft.com/en-us/download/details.aspx?id=27115, You need to right click your client project properties and refer client dlls(Microsoft.ApplicationServer.Caching.Client.dll and Microsoft.ApplicationServer.Caching.Core.dll.) from c:\Program Files\Windows Server Appfabric or whichever folder you installed it to. (While installing, you should have checked the check box 'install client'
Refer this link for more details: http://msdn.microsoft.com/en-us/library/hh334398(v=azure.10).aspx
回答2:
Microsoft Windows Server AppFabric Cookbook, chapter Installing Cache Client Assemblies, paragraph How it works... reminded me again, just as @Alfan tiried, to check, for the nth time, server service executable file version and client assemblies file version on the disk.
The confusion is that I have installed AppFabric Cache from MS download center page (...\Program Files\AppFabric 1.1 for Windows Server
), but already had Windows Azure SDK v2.2 installed (...\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.2\ref\Caching
). Both installs have Microsoft.ApplicationServer.Caching.Client.dll, Microsoft.ApplicationServer.Caching.Core.dll files.
I have referenced SDK's files (v 1.0.5137.0) and versions did not match. I referenced assemblies from AppFabric Cache (v 1.0.4632.0) folder which has resolved my problem.
Side note
Both file versions report same version number when running AppDomain.CurrentDomain.GetAssemblies()
from client application.
来源:https://stackoverflow.com/questions/24824968/windows-server-appfabriccache-exception-check-the-client-version