title: Cache referred to does not exist
body: <p><strong>History</strong>
  In my development environment I've battled a reoccurring error with running Windows Azure Emulator. To resolve before I created a new Solution and projects based on the Azure template, along with reinstalling the October 2012 update SDK. Then I had to copy over all the files into the new projects. Before going through all that, since I know it can work, I wanted to see if there was something else I can do. </p>
  
  <p><strong>Setup</strong></p>
  
  <ul>
  <li>Windows 8 </li>
  <li>Visual Studio 2012 Update 1</li>
  <li>IIS Express 8</li>
  <li>Windows Azure Tools - October 2012</li>
  <li>Windows Azure Caching 1.8.1.0 </li>
  <li>ASP.NET MVC 4.0 project</li>
  <li>Web Role (2 Instances)</li>
  <li>Cache Worker Role (2 Instances)</li>
  <li>Caching Enabled on Cache Work Roles and set to Dedicated Role (Local Role state is: UseDevelopmentStorage=true)</li>
  <li>Session uses Distributed Cache</li>
  <li>Output Cache uses Distributed Cache</li>
  </ul>
  
  <p><strong>Web.config settings</strong></p>
  
  <pre><code>    &lt;sessionState mode="Custom" customProvider="AFCacheSessionStateProvider" cookieName="abc_session"&gt;
            &lt;providers&gt;
              &lt;add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState" /&gt;
            &lt;/providers&gt;
          &lt;/sessionState&gt;
  
  &lt;outputCache defaultProvider="AFCacheOutputCacheProvider"&gt;
          &lt;providers&gt;
            &lt;add name="AFCacheOutputCacheProvider" type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheOutputCache" /&gt;
          &lt;/providers&gt;
        &lt;/outputCache&gt;
      &lt;/caching&gt;
  
    &lt;dataCacheClients&gt;
      &lt;dataCacheClient name="default"&gt;
        &lt;autoDiscover isEnabled="true" identifier="AppNameCacheWorkerRole" /&gt;
      &lt;/dataCacheClient&gt;
    &lt;/dataCacheClients&gt;
  </code></pre>
  
  <p><strong>Error Details</strong></p>
  
  <pre><code>ErrorCode&lt;ERRCA0009&gt;:SubStatus&lt;ES0001&gt;:Cache referred to does not exist
  [DataCacheException: ErrorCode&lt;ERRCA0009&gt;:SubStatus&lt;ES0001&gt;:Cache referred to does not exist. Contact administrator or use the Cache administration tool to create a Cache.]
     Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination) +767
     Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination) +149
     Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable`1 servers, RequestBody request, Func`3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy) +967
     Microsoft.ApplicationServer.Caching.&lt;&gt;c__DisplayClass4.&lt;Initialize&gt;b__1(RequestBody req) +198
     Microsoft.ApplicationServer.Caching.SocketClientProtocol.SendReceive(IVelocityRequestPacket request, Func`2 delegate, EndpointID&amp; destination) +121
     Microsoft.ApplicationServer.Caching.SocketClientProtocol.Initialize(IEnumerable`1 servers) +1011
     Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate) +1103
     Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +131
     Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
     Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +356
     Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.CreateInternalProvider(IHttpRuntime httpRuntime, OutputCacheInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +399
     Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.GetInternalProvider() +315
     Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.Get(String key) +54
     System.Web.Caching.OutputCache.Get(String key) +80
     System.Web.Caching.OutputCacheModule.OnEnter(Object source, EventArgs eventArgs) +341
     System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +165
  </code></pre>
  
  <p>Misc Notes:</p>
  
  <ul>
  <li>The same configuration works fine when it is deployed to Azure, so has something to do with my local environment. </li>
  <li>IIS Express was crashing when I had more than one instance of web roles setup, and I found a suggestion to run the Visual Studio 2010 SP1 to resolve. I had VS2010 on the system because one tools (believe it was SQL) installed it. Installing SP1 resolved the issue with IIS Express crashing, but then this error reappeared. </li>
  <li>If I comment out the OutputCache node listed above the error goes away.</li>
  <li>If I switch the Cache Worker Role from Dedicated Role to Co-located Role the error goes away.</li>
  </ul>