3

Not wanting to leave a client.ncconf lying aside my exe, I wish to be able to specify the path to the client.ncconf file programatically. How may I? I am using NCache 4.4SP1 Open Source.

The methods I am using are mainly Web.Caching.NCache.InitializeCache and Cache.Get.

Laurent LA RIZZA
  • 2,905
  • 1
  • 23
  • 41

1 Answers1

1

It picks the config from %NCHOME% InstallDir/config. Just add the following in your AppSettings

<add key="InstallDir" value="C:\temp"/>

Also, all the client configurations can be specified programmatically using the CacheInitParams. You can

namespace Alachisoft.NCache.Web.Caching
{
    public class CacheInitParams : ICloneable
    {
        public CacheInitParams();

        public string BindIP { get; set; }
        public ClientCacheSyncMode ClientCacheSyncMode { get; set; }
        public int ClientRequestTimeOut { get; set; }
        public int CommandRetries { get; set; }
        public int CommandRetryInterval { get; set; }
        public int ConnectionRetries { get; set; }
        public int ConnectionTimeout { get; set; }
        public string DefaultReadThruProvider { get; set; }
        public string DefaultWriteThruProvider { get; set; }
        public bool LoadBalance { get; set; }
        public CacheMode Mode { get; set; }
        [Obsolete("This property is deprecated. Please use the 'ServerList' property instead.", false)]
        public int Port { get; set; }
        public SecurityParams PrimaryUserCredentials { get; set; }
        public int RetryConnectionDelay { get; set; }
        public int RetryInterval { get; set; }
        public SecurityParams SecondaryUserCredentials { get; set; }
        [Obsolete("This property is deprecated. Please use the 'ServerList' property instead.", false)]
        public string Server { get; set; }
        public CacheServerInfo[] ServerList { get; set; }

        public object Clone();
    }
}
Basit Anwer
  • 6,742
  • 7
  • 45
  • 88
  • Do you know at what time it evaluates the `%NCHOME%` variable? Would setting the environment variable at the beginning of the program be enough to change the location? – Laurent LA RIZZA Feb 24 '16 at 18:26
  • I am sorry Basit, but `App.config` does not qualify for "programatically". I only know the directory containing the `client.ncconf` the from the command line parameters of my app. – Laurent LA RIZZA Feb 25 '16 at 12:46
  • 1
    Use [ConfigurationManager Class](https://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager%28v=vs.110%29.aspx) – Basit Anwer Feb 26 '16 at 06:46
  • @LaurentLARIZZA does it help ? – Basit Anwer Mar 07 '16 at 06:23
  • @BasitAnwer this answer didnt solve, ncache still cant find the client.nconf, even putting the file on the same path of the application – Lucas Roselli Sep 29 '16 at 19:55