title: Kafka - Error in Instantiating Producer Class in ASP.Net Core
body: <p>I am using <code>Confluent.Kafka</code></p>
  
  <pre><code>string kafkaEndpoint = "127.0.0.1:9092";
  
          string kafkaTopic = "testtopic";
  
          var producerConfig = new Dictionary&lt;string, object&gt; { { "bootstrap.servers", kafkaEndpoint } };
  
          using (var producer = new Producer&lt;Null, string&gt;(producerConfig, null, new StringSerializer(Encoding.UTF8)))
          {
              // Send 10 messages to the topic
              for (int i = 0; i &lt; 10; i++)
              {
                  var message = $"Event {i}";
                  var result = producer.ProduceAsync(kafkaTopic, null, message).GetAwaiter().GetResult();
                  Console.WriteLine($"Event {i} sent on Partition: {result.Partition} with Offset: {result.Offset}");
              }
          }
  </code></pre>
  
  <p>I am getting the following compile time error:</p>
  
  <blockquote>
    <p>Producer.ProduceAsync(TopicPartition, Message)' is inaccessible due to its protection level</p>
  </blockquote>
  
  <p>Using <code>ProducerBuilder</code> like this:</p>
  
  <pre><code>var result = producer.ProduceAsync(kafkaTopic, new Message&lt;Null, MyClass&gt;{ Value = myObject}).GetAwaiter().GetResult();
  </code></pre>
  
  <p>shows error:</p>
  
  <pre><code>Cannot convert from 'Confluent.Kafka.Message&lt;Confluent.Kafka.Null, MyClass&gt;' to 'Confluent.Kafka.Message&lt;Confluent.Kafka.Null, string&gt;
  </code></pre>