'AvroDeserializer<GenericRecord>' 不包含 'AsSyncOverAsync' 的定义并且没有可访问的扩展方法

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

我已经更新了我的 unity 项目 dll,之后我收到了这个错误

'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?)

在这一行

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

我不知道为什么这不是方法不可用。这是我的 dll 文件:

我仅使用 program.cs 中的这段代码成功地复制了一个小解决方案,我可以构建该解决方案并查看位于 Confluent.Kafka.SyncOverAsync 命名空间中的 AsSyncOverAsync 扩展方法。

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()) { }
    }
}

这是 *.csproj 文件:

<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>

您似乎缺少 Confluent.SchemaRegistry.Serdes.Avro 包,因此尝试从 Nuget 手动安装它们。