# .NET client Version 9.0.0 ElasticsearchClientProductRegistration ArgumentNullException

**URL:** <https://discuss.elastic.co/t/net-client-version-9-0-0-elasticsearchclientproductregistration-argumentnullexception/379174>\
**Category:** Elasticsearch\
**Tags:** language-clients, runtime-fields\
**Created:** [June 14, 2025, 2:26pm UTC](https://discuss.elastic.co/t/net-client-version-9-0-0-elasticsearchclientproductregistration-argumentnullexception/379174 "2025-06-14T14:26:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahdi\_Abbasi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mahdi_abbasi/32/111212_2.png) [@Mahdi\_Abbasi](https://discuss.elastic.co/u/Mahdi_Abbasi)\
**Post date:** [June 14, 2025, 2:26pm UTC](https://discuss.elastic.co/t/net-client-version-9-0-0-elasticsearchclientproductregistration-argumentnullexception/379174/1 "2025-06-14T14:26:58Z")

</div>

**Elastic.Clients.Elasticsearch version** :9.0.0

**Elasticsearch version** :9.0.2

**.NET runtime version** :7.0.101

**Operating system version** :Windows 10.0.19045

**Description of the problem** :  
I am trying to connect to the elasticsearch .net client in my [asp.net](http://asp.net) mvc nopcommerce project.  
this is my code:  
namespace Nop.Services.Elasticsearch  
{  
public sealed class ElasticSeachConfiguration  
{  
private static readonly Lazy LazyClient = new Lazy(CreateClient);

```auto
    public static ElasticsearchClient ESContext => LazyClient.Value;

    private const string Username = "user";
    private const string Password = "pass";
    // private const string Fingerprint = "<YOUR_CA_FINGERPRINT>"; // optional

    private static ElasticsearchClient CreateClient()
    {
        var connectionString = LoadConnection();

        if (string.IsNullOrWhiteSpace(connectionString))
            throw new InvalidOperationException("Elasticsearch connection string is missing or invalid in App_Data/ElasticSettings.txt");

        Uri nodeUri;
        try
        {
            nodeUri = new Uri(connectionString);
        }
        catch (UriFormatException ex)
        {
            throw new InvalidOperationException("Invalid Elasticsearch URI format in ElasticSettings.txt", ex);
        }

        var pool = new SingleNodePool(nodeUri);

        var settings = new ElasticsearchClientSettings(pool)
            .Authentication(new BasicAuthentication(Username, Password))
            .CertificateFingerprint("<YOUR_CA_FINGERPRINT>")
            .EnableDebugMode();

        return new ElasticsearchClient(settings);
    }

    static void ConfigureOptions(JsonSerializerOptions o)
    {
        o.PropertyNamingPolicy = null;
    }

    private static string LoadConnection()
    {
        var filePath = Path.Combine(MapPath("~/App_Data/"), "ElasticSettings.txt");

        if (!File.Exists(filePath))
            throw new FileNotFoundException("Elasticsearch connection config not found at: " + filePath);

        var text = File.ReadAllText(filePath).Trim();
        if (string.IsNullOrWhiteSpace(text))
            throw new InvalidOperationException("ElasticSettings.txt is empty or contains only whitespace.");

        return text;
    }

    private static string MapPath(string path)
    {
        if (HostingEnvironment.IsHosted)
            return HostingEnvironment.MapPath(path);

        var baseDir = AppDomain.CurrentDomain.BaseDirectory;
        path = path.Replace("~/", "").TrimStart('/').Replace('/', '\\');
        return Path.Combine(baseDir, path);
    }

    private ElasticSeachConfiguration() { }
}

```

}

but i get the following error:  
System.TypeInitializationException  
HResult=0x80131534  
Message=The type initializer for 'Elastic.Clients.Elasticsearch.ElasticsearchClientProductRegistration' threw an exception.  
Source=Elastic.Clients.Elasticsearch  
StackTrace:  
at Elastic.Clients.Elasticsearch.ElasticsearchClientSettingsBase`1..ctor(NodePool nodePool, IRequestInvoker requestInvoker, SourceSerializerFactory sourceSerializerFactory, IPropertyMappingProvider propertyMappingProvider) at Elastic.Clients.Elasticsearch.ElasticsearchClientSettings..ctor(NodePool nodePool) at Nop.Services.Elasticsearch.ElasticSeachConfiguration.CreateClient() in D:\Projects\IrsaProjects\Abar1\Libraries\Nop.Services\ElasticsearchService\ElasticSeachConfiguration.cs:line 43 at System.Lazy`1.CreateValue()  
--- End of stack trace from previous location ---  
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()  
at System.Lazy`1.get_Value() at Nop.Services.Elasticsearch.ElasticSeachConfiguration.get_ESContext() in D:\Projects\IrsaProjects\Abar1\Libraries\Nop.Services\ElasticsearchService\ElasticSeachConfiguration.cs:line 18 at Nop.Services.ElasticsearchService.ConnectToElasticService.EsClient() in D:\Projects\IrsaProjects\Abar1\Libraries\Nop.Services\ElasticsearchService\ConnectToElasticService.cs:line 16 at Nop.Web.Controllers.CatalogController.<CategoriesIconMode>b__89_0() in D:\Projects\IrsaProjects\Abar1\Presentation\Nop.Web\Controllers\CatalogController.cs:line 2308 at Nop.Core.Caching.CacheExtensions.Get[T](ICacheManager cacheManager, String key, Int32 cacheTime, Func`1 acquire) in D:\Projects\IrsaProjects\Abar1\Libraries\Nop.Core\Caching\Extensions.cs:line 39  
at Nop.Core.Caching.CacheExtensions.Get[T](ICacheManager cacheManager, String key, Func`1 acquire) in D:\Projects\IrsaProjects\Abar1\Libraries\Nop.Core\Caching\Extensions.cs:line 20 at Nop.Web.Controllers.CatalogController.CategoriesIconMode() in D:\Projects\IrsaProjects\Abar1\Presentation\Nop.Web\Controllers\CatalogController.cs:line 2306 at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)  
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)  
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)  
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b\_\_3d()  
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.\<\>c\_\_DisplayClass46.b\_\_3f()

Inner Exception 1:  
ArgumentNullException: Value cannot be null.  
Parameter name: input

In the previous verison(v8.x) of the client I never experienced such an issue.

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [June 16, 2025, 7:42am UTC](https://discuss.elastic.co/t/net-client-version-9-0-0-elasticsearchclientproductregistration-argumentnullexception/379174/2 "2025-06-16T07:42:01Z")

</div>

Hi @Mahdi_Abbasi ,

I saw that you already created an issue about this on GitHub. I’ll respond back to you there when I had a deeper look.
