Using the open source Alachisoft Ncache API to add an object return "Object reference not set to object instance."

When I start using the open source version of NCache, I use the NCache API to store the value of an object. During POC, when I add an object to NCache, it always throws an "Object reference not set to an object instance". error message. And I'm sure the object is not null. The following is sample code:

 /** For testing only */
            Cache cache = null;
            try {
                cache = NCache.InitializeCache("mycache");
            } catch (Exception ex) {
            }
         response = ....

  CacheItem cacheItem = new CacheItem(response);
  cache.Add("testNCache", cacheItem);
+4
source share

Source: https://habr.com/ru/post/1621219/


All Articles