0

Im trying to achieve hazelcast embedded architecture, on my local machine, so wrote two C# console apps, different processes(two vs instances). So my main goal is to first app write data, and second to read the same. My code look like bellow

ConsoleApp1(standard template) :

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());
        }

    }

And Second

 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));
        clientConfig.GetSerializationConfig().AddSerializerConfig(sc);
        IHazelcastInstance client = Hazelcast.Client.HazelcastClient.NewHazelcastClient(clientConfig);
        IMap<string, Person> mapPersons = client.GetMap<string, Person>("persons");
        Console.WriteLine(mapPersons.Size());
        foreach (var person in mapPersons.Values() )
        {
            Console.WriteLine(person.Name);
        }


    }

When i run second app, i get error "Hazelcast.IO.Serialization.HazelcastSerializationException: 'Unable to find assembly 'ConsoleApp1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'."

How to setup this kind environment?

Thanks

  • Do you have this problem: https://stackoverflow.com/questions/13090955/deserialization-exception-unable-to-find-assembly Did you define Person in two different assemblies? – ihsan demir Dec 21 '17 at 10:26
  • Well, yeah, i've defined person in both solutions, but is there a way to fix by configuring ClienConfig(), and not making lib? – Miki Miljkovic Dec 21 '17 at 10:36
  • what do you mean by "configuring ClienConfig()". I did not understand the question. – ihsan demir Dec 21 '17 at 14:41

1 Answers1

0

Found the solution, i only moved class Person to separate class library in both solutions, and it worked. Very interesting.