问题
I am getting the following error when I run the simple Windows Server App Fabric 1.0 demo console application:
ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.
Please help me.. What am I missing..?? I have looked every where on the internet and nothing seems to be fixing this issue. thanks..
My application is as follows:
static void Main(string[] args)
{
var factory = new Microsoft.ApplicationServer.Caching.DataCacheFactory(); <--- *** Error here
var cache = factory.GetDefaultCache();
var key = "mykey";
var obj = cache[key];
if (obj == null)
{
cache[key] = "I am data for caching";
}
obj = cache[key];
Console.WriteLine(obj);
Console.Read();
}
My app.config is as follows:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="dataCacheClients"
type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" />
</configSections>
<dataCacheClients>
<dataCacheClient>
<hosts>
<host name="MyMachineNameHere" cachePort="22233" />
</hosts>
</dataCacheClient>
</dataCacheClients>
</configuration>
回答1:
I updated my appconfig as follows and it worked....
<?xml version="1.0"?>
<configuration>
<!--configSections must be the FIRST element -->
<configSections>
<!-- required to read the <dataCacheClient> element -->
<section name="dataCacheClient"
type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
<!-- cache client -->
<dataCacheClient>
<!-- cache host(s) -->
<hosts>
<host
name="MyMachineNameHere"
cachePort="22233"/>
</hosts>
</dataCacheClient>
</configuration>
来源:https://stackoverflow.com/questions/13279038/appfabric-1-0-error-server-collection-cannot-be-empty