Hazelcast c#来自两个不同进程的读取

时间:2017-12-21 10:02:19

标签: c# caching hazelcast

我试图在我的本地机器上实现hazelcast嵌入式架构,因此编写了两个C#控制台应用程序,不同的进程(两个vs实例)。所以我的主要目标是首先应用程序写入数据,然后再读取相同内容。我的代码看起来像吼叫

ConsoleApp1(标准模板):

function1

第二次

static void Main(string[] args)
    {
        var clientConfig = new ClientConfig();
        clientConfig.GetNetworkConfig().AddAddress("127.0.0.1");

        var sc = new SerializerConfig()
            .SetImplementation(new CustomSerializer())
            .SetTypeClass(typeof(Person));

            //Custom Serialization setup up for Person Class.

            clientConfig.GetSerializationConfig().AddSerializerConfig(sc);


        IHazelcastInstance client = HazelcastClient.NewHazelcastClient(clientConfig);
        //All cluster operations that you can do with ordinary HazelcastInstance

        IMap<string, Person> mapCustomers = client.GetMap<string, Person>("persons");
        mapCustomers.Put("1", new Person("Joe", "Smith"));
        mapCustomers.Put("2", new Person("Ali", "Selam"));
        mapCustomers.Put("3", new Person("Avi", "Noyan"));

        ICollection<Person> persons = mapCustomers.Values();
        foreach (var person in persons)
        {
            Console.WriteLine(person.ToString());
        }

    }

当我运行第二个应用时,我收到错误&#34; Hazelcast.IO.Serialization.HazelcastSerializationException:&#39;无法找到程序集&#39; ConsoleApp1,Version = 1.0.0.0,Culture = neutral ,PublicKeyToken = null&#39;。&#34;

如何设置此类环境?

由于

1 个答案:

答案 0 :(得分:0)

找到解决方案,我只将类Person移动到两个解决方案中的单独的类库中,并且它有效。非常有趣。