2017-12-21 11 views
0

私のローカルマシン上でヘイルキャストエンベデッドアーキテクチャを実現しようとしているので、2つのC#コンソールアプリ、異なるプロセス(2つのインスタンスと2つのインスタンス)を書きました。だから私の主な目標は、最初にデータ書き込みをアプリにし、2番目に同じデータを読み込むことです。Hazelcast C#2つの異なるプロセスから読み込みを書き込む

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

    } 

と第二

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


    } 

私は2番目のアプリを実行すると、私はエラー「Hazelcast.IO.Serialization.HazelcastSerializationExceptionを取得:怒鳴る

ConsoleApp1(標準テンプレート)のように私のコードを見て'アセンブリ' ConsoleApp1、バージョン= 1.0.0.0、Culture =ニュートラル、PublicKeyToken = null 'を見つけることができません。

このような環境を設定するにはどうすればよいですか?

おかげ

+0

この問題がありますか?https://stackoverflow.com/questions/13090955/deserialization-exception-unable-to-find-assembly 2つの異なるアセンブリでPersonを定義しましたか? –

+0

さて、両方のソリューションで人を定義しましたが、ClienConfig()を設定してlibを作成しないように修正する方法がありますか? –

+0

"ClienConfig()"の設定はどういう意味ですか?私はその質問を理解していませんでした。 –

答えて

0

は解決策を見つけ、私は両方のソリューションでクラスライブラリを分離するために、クラスPersonを移動し、それが働きました。とても興味深い。

関連する問題