Running GemFire C# Native Client 7.0 using non-generic API fails with the error: GemStone.GemFire.Cache.NotConnectedException
search cancel

Running GemFire C# Native Client 7.0 using non-generic API fails with the error: GemStone.GemFire.Cache.NotConnectedException

book

Article ID: 294193

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

Symptoms:
Running GemFire C# Native Client 7.0 using non-generic API fails with the error:
GemStone.GemFire.Cache.NotConnectedException (2041452)
  • When running GemFire C# Native Client7.0 using non-generic API, you see the error:

    GemStone.GemFire.Cache.NotConnectedException
  • For example, the C# code appears similar to:
    using GemStone.GemFire.Cache;
    ......
    
        CacheFactory cacheFactory = CacheFactory.CreateCacheFactory();
        Cache cache = cacheFactory
                            .AddServer("localhost", 40404)
                            .SetPRSingleHopEnabled(true)
                            .SetSubscriptionEnabled(true)
                            .Create();   
    
       RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY);
       Region region = regionFactory.Create("exampleRegion");
       region.Put("111", "112233");
  • You see an exception similar to:
    An exception occurred: GemStone.GemFire.Cache.NotConnectedException: Region::put: not connected to GemFire ---> GemStone.GemFire.Cache.GemFireException:   No stack available.
    
       --- End of inner exception stack trace ---
       at GemStone.GemFire.Cache.Region.Put(CacheableKey key, Serializable value, IGFSerializable callback)
       at GemStone.GemFire.Cache.Region.Put(CacheableKey key, Serializable value)
       at Examples.HelloWorld.Main() in C:\kyoinstall\Gemfire\TestCenter\TradingScreenGemfire7\Client\test1\application\client\HelloWorld\HelloWorld.cs:line 51
       ---[ Press <Enter> to End the Application ]---

Environment


Cause

This issue occurs because the non-generic API in GemFire Native Client 7.0 is deprecated.

Resolution

In GemFire Native Client 7.0, the non-generic API should be converted to generic API in the code.
Note: VMware does not provide any reference guide for the API conversion. You can convert non-generic API to generic API using the Native Client User Guide and the API document.

Sample code conversion

//namespace change
using GemStone.GemFire.Cache.Generic;
......
 
    CacheFactory cacheFactory = CacheFactory.CreateCacheFactory();
    Cache cache = cacheFactory
                        .AddServer("localhost", 40404)
                        .SetPRSingleHopEnabled(true)
                        .SetSubscriptionEnabled(true)
                        .Create();   
 
   RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY);
 
   //Region-->IRegion
   IRegion<String, String> region = regionFactory.Create<String, String>("exampleRegion");
   
   //Using the generic IDictionary API or by using the .NET Region.Put
   region[strKey] = strValue;