Search code examples
c#apache-kafkaavroconfluent-platform

'AvroDeserializer<GenericRecord>' does not contain a definition for 'AsSyncOverAsync' and no accessible extension method


I have update my unity project dlls and after that i am getting this error

'AvroDeserializer' does not contain a definition for 'AsSyncOverAsync' and no accessible extension method 'AsSyncOverAsync' accepting a first argument of type 'AvroDeserializer' could be found (are you missing a using directive or an assembly reference?)

at this line

  .SetValueDeserializer(new AvroDeserializer<GenericRecord>(schemaRegistry).AsSyncOverAsync())

I don't know why this is not method is not available. Here are my dll files: enter image description here


Solution

  • I've managed to reproduced a small solution only with this code in program.cs, I can build the solution and see the AsSyncOverAsync extension method which located in Confluent.Kafka.SyncOverAsync namespace.

    class Program
    {
        static void Main(string[] args)
        {            
            IEnumerable<KeyValuePair<string, string>> consumerConfig = new List<KeyValuePair<string, string>>();
            using (var schemaRegistry = new CachedSchemaRegistryClient(new SchemaRegistryConfig { }))
            using (var consumer =
                new Confluent.Kafka.ConsumerBuilder<string, GenericRecord>(consumerConfig)
                    .SetValueDeserializer(new AvroDeserializer<GenericRecord>(schemaRegistry).AsSyncOverAsync())
                    .Build()) { }
        }
    }
    

    This is the *.csproj file:

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.1</TargetFramework>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Confluent.Kafka" Version="1.4.0" />
        <PackageReference Include="Confluent.SchemaRegistry.Serdes.Avro" Version="1.4.0" />
      </ItemGroup>
    
    </Project>
    

    It looks like you are missing the Confluent.SchemaRegistry.Serdes.Avro package so try manually install them both from Nuget.

    enter image description here