When working with AppFabric Caching features in an application (i.E. web service) hosted in IIS, you might experience following problem:
=== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = Microsoft.ApplicationServer.Caching.Core, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Appbase = file:///D:/Tfs/ble/bla...
LOG: Initial PrivatePath = D:\Tfs\ble\bla\bin
Calling assembly : Jettware.System, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Tfs\ble\bla\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.ApplicationServer.Caching.Core, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Depending on the place in code where Caching objects are initialized, the same error can be detected as next snippet shows too:
Note that we have experienced the same problem with other libraries like Entity Framework. Anyhow there are several error messages which in fact indicates the same problem.
My favorite one is: “".. ‘localhost’ cannot be resolved”. This error would get the caller of web service operation which fails with one of exceptions shown above.
I always say “If you don’t know what is the problem, then the answer could be probably Kerberos.” Fortunately this time is not Kerberos in play :). It is much wars. :(
The real problem is however security or more precisely impersonation level. This can happen when your service allows or requires the impersonation and when impersonation is done.
For example, the exception can be caused by this code:
This code will enforce the thread to impersonate the thread user as a caller of an external service. In this case DistributedCacheService. Because the impersonated user is possibly not permitted to instantiate the cache object (do not ask me why), on eof exceptions shown above will be thrown.
Here the workaround to solve this problem:
The new DataCacheFactory has to be called not impersonated (with pool user) once and anywhere in the application domain. After this all other calls to all cache class constructors will work.
public class myclass
DataCacheFactory f = new DataCacheFactory();
public void myMethod