AppFabric 1.0 error Server collection cannot be empty

自作多情 提交于 2019-12-24 04:46:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!