ConfigurationBuilder NullReferenceException issue
Here is the code which produces the NULL reference issue some times. This code runs in a threading scenario and we are in need to load the JSON file dynamically.
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory() + "/sets")
.AddJsonFile($"settings.{name}.json", optional: false)
.Build();
var result = configuration.Get<Settings>();
The above code works well. However, we are getting the below-mentioned error randomly for the last one month. We have done load testing many times and this code works well. We are not sure when exactly the runtime produces this error and it's random always. Can anyone please let me know if it could be an issue with threads? The code exactly fails on the line "var translations = configuration.Get();"
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
ConfigurationBuilder NullReferenceException issue
Here is the code which produces the NULL reference issue some times. This code runs in a threading scenario and we are in need to load the JSON file dynamically.
The above code works well. However, we are getting the below-mentioned error randomly for the last one month. We have done load testing many times and this code works well. We are not sure when exactly the runtime produces this error and it's random always. Can anyone please let me know if it could be an issue with threads? The code exactly fails on the line "var translations = configuration.Get();"