Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# AppFabric 1.0错误服务器集合不能为空_C#_Asp.net_Appfabric_Windows Server_Appfabric Cache - Fatal编程技术网

C# AppFabric 1.0错误服务器集合不能为空

C# AppFabric 1.0错误服务器集合不能为空,c#,asp.net,appfabric,windows-server,appfabric-cache,C#,Asp.net,Appfabric,Windows Server,Appfabric Cache,运行简单的Windows Server App Fabric 1.0演示控制台应用程序时,我遇到以下错误: ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty. ErrorCode:SubStatus:Server集合不能为空。 请帮帮我。。我错过了什么。。??我在互联网上到处查看,似乎没有任何东西能解决这个问题。谢谢 我的申请如下: static void Main(str

运行简单的Windows Server App Fabric 1.0演示控制台应用程序时,我遇到以下错误:

ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.
ErrorCode:SubStatus:Server集合不能为空。
请帮帮我。。我错过了什么。。??我在互联网上到处查看,似乎没有任何东西能解决这个问题。谢谢

我的申请如下:

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();
}
static void Main(字符串[]args)
{

var factory=new Microsoft.ApplicationServer.Caching.DataCacheFactory();我更新了我的appconfig,如下所示,它运行正常

<?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>

<?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>