Alachisoft / NCache

NCache: Highly Scalable Distributed Cache for .NET
http://www.alachisoft.com
Apache License 2.0
647 stars 123 forks source link

'client.ncconf' not found or does not contain server information #11

Open gigi81 opened 7 years ago

gigi81 commented 7 years ago

When running my Integration tests through NUnit and resharper I get this error. ''client.ncconf' not found or does not contain server information

The client.ncconf file is available both in the test dll binary directory AND in the NCache installation folder. So at least one of the two should be picked up by NCache

Kal-Alachisoft commented 7 years ago

Hi @gigi81 ,

I can share my insight on this. "'Client.ncconf' not found or does not contain server information" error is only thrown when NCache is unable to find the cache with the name specified inside this file that you have specified in cache initialize call or when it is unable to access the client.ncconf file. This file contains the information required to connect to the Server where your cache exists.

Please make sure that you have a cache configured on an NCache server and you also have your own machine (where you plan to run applications from) added under client for this cache so that you have configurations added inside Client.ncconf file to connect to this cache. You can use AddClientnode tool to add Client side configurations inside Client.ncconf file.

Please note that I going to refer to sections from the document present at this link below.

http://www.alachisoft.com/resources/docs/ncache/ncache-open-source-guide.pdf

You can follow below steps.

• Create a cache on a given server (Section 3.1)

createcache testcache /s 20.200.20.100 /S 1024 /t partitioned

• Add your application machine under this cache as a client (Section 3.3)

addclientnode testcache /s 20.200.20.100 /e 20.200.20.102

• Stress test tool to verify client is able to connect to the server (Section 3.5.4).

stresstesttool testcache

• Review perfmon counters (Section 4.1).

Alternatively, you can also use CacheInitParams (Section 8.1.3) to specify the IP address where the cache is hosted. CacheInitParams allow you to bypass Client.ncconf and all information to connect to the cache can be specified within the application code.

Please confirm on the above and then I can help you further.

juanmanuelrios commented 6 years ago

I had a similiar problem trying to initialize NCache from a windows service. When I call to NCache.Initialize an exception araise: 'System.ArgumentException' in System.Configuration.dll ("El parámetro 'exePath' no es válido.").

Partial stack information is as follow:

System.Configuration.dll!System.Configuration.ClientConfigPaths..ctor(string exePath = {unknown}, bool includeUserConfig = {unknown})   C#
System.Configuration.dll!System.Configuration.ClientConfigPaths.GetPaths(string exePath = {unknown}, bool includeUserConfig = {unknown})    C#
System.Configuration.dll!System.Configuration.ClientConfigurationHost.GetStreamName(string configPath = {unknown})  C#
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.InitConfigFromFile()  C#
System.Configuration.dll!System.Configuration.BaseConfigurationRecord.Init(System.Configuration.Internal.IInternalConfigRoot configRoot = {unknown}, System.Configuration.BaseConfigurationRecord parent = {unknown}, string configPath = {unknown}, string locationSubPath = {unknown})    C#
System.Configuration.dll!System.Configuration.MgmtConfigurationRecord.Init(System.Configuration.Internal.IInternalConfigRoot configRoot = {unknown}, System.Configuration.Internal.IInternalConfigRecord parent = {unknown}, string configPath = {unknown}, string locationSubPath = {unknown}) C#
System.Configuration.dll!System.Configuration.Internal.InternalConfigRoot.GetConfigRecord(string configPath = {unknown})    C#
System.Configuration.dll!System.Configuration.Configuration..ctor(string locationSubPath = {unknown}, System.Type typeConfigHost = {unknown}, object[] hostInitConfigurationParams = {unknown}) C#
System.Configuration.dll!System.Configuration.ClientConfigurationHost.OpenExeConfiguration(System.Configuration.ConfigurationFileMap fileMap = {unknown}, bool isMachine = {unknown}, System.Configuration.ConfigurationUserLevel userLevel = {unknown}, string exePath = {unknown})    C#
System.Configuration.dll!System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(System.Configuration.ConfigurationFileMap fileMap = {unknown}, bool isMachine = {unknown}, System.Configuration.ConfigurationUserLevel userLevel = {unknown}, string exePath = {unknown}, bool preLoad = {unknown}) C#
Alachisoft.NCache.Common.dll!Alachisoft.NCache.Common.Util.ServiceConfiguration.Load()  C#
Alachisoft.NCache.Common.dll!Alachisoft.NCache.Common.Util.ServiceConfiguration..cctor()    C#
Alachisoft.NCache.Common.dll!Alachisoft.NCache.Common.AppUtil..cctor()  C#
Alachisoft.NCache.Web.dll!Alachisoft.NCache.Web.DirectoryUtil.SearchGlobalDirectory(string directoryName = {unknown}, bool createNew = {unknown}, out string path = {unknown})  C#
Alachisoft.NCache.Web.dll!Alachisoft.NCache.Web.DirectoryUtil.SearchGlobal(string fileName = {unknown}, out Alachisoft.NCache.Web.Search result = {unknown})    C#
Alachisoft.NCache.Web.dll!Alachisoft.NCache.Web.RemoteClient.Config.ClientConfiguration.LoadConfiguration() C#
Alachisoft.NCache.Web.dll!Alachisoft.NCache.Web.Caching.Cache.LoadRWTrhuSettings()  C#
Alachisoft.NCache.Web.dll!Alachisoft.NCache.Web.Caching.Cache..ctor(Alachisoft.NCache.Web.Caching.CacheImplBase objectCache = {unknown}, string cacheId = {unknown}, Alachisoft.NCache.Web.Statistics.PerfStatsCollector2 perfStatsCollector = {unknown})   C#
Alachisoft.NCache.Web.dll!Alachisoft.NCache.Web.Caching.NCache..cctor() C#

As I can understand from error description, and call stack information, when it tries to read client,ncconfig file something wrong happens to OpenExeConfiguration method of System.Configuration assembly.

I also tried to set %NCHOME% environment variable to a path where client.ncconf exists, but the problem still happens.

My goal is to use NCache from a windows service application where NCache server is not installed.

Please can you give me some hints on this issue?

Thanks in advance.

Kal-Alachisoft commented 6 years ago

Hi @juanmanuelrios ,

I'll work on this with my team to understand the root cause for this. In the meantime, please confirm on the following

Kal Alachisoft Support

BogdanDamianC commented 4 years ago

with .net core 3.1 the error happens in any situation where you are running the app from a different directory than the one where the app is in, for windows services this is happens by default, loading the local client.ncconf will just not work.

it would be nice to make the public method that can be called to initialize the cache using any location, this would probably solve this problem and allow for an easier use

something like NCache.Initialize(string pathto the client.ncconf file)

Rich-Ott commented 4 years ago

I just ran into this issue trying to get a .NET Core 3.1 app running as a Windows Service with NCache.

It appears that NCache tries to use System.Environment.CurrentDirectory to find the client.ncconf file. For Windows Services in particular, this call typically resolves to "C:\Windows\System32" and not the application's base directory where the config file actually resides.

I was able to work around the issue by calling Directory.SetCurrentDirectory(AppContext.BaseDirectory) in my program's Main() function. This could also work for non-Windows Service applications.