Skip to content

.Net: Could not load file or assembly Microsoft.Bcl.AsyncInterfaces exception #2953

@WeihanLi

Description

@WeihanLi

Describe the bug

Could not load file or assembly Microsoft.Bcl.AsyncInterfaces exception when using the redis memory storage

To Reproduce

var apiEndpoint = Guard.NotNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_OPENAI_API_ENDPOINT"));
var apiKey = Guard.NotNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY"));
var kernelBuilder = new KernelBuilder();
kernelBuilder.WithAzureChatCompletionService("gpt-35-turbo", apiEndpoint, apiKey);
kernelBuilder.WithAzureTextEmbeddingGenerationService("text-embedding-ada-002", apiEndpoint, apiKey);
// kernelBuilder.WithMemoryStorage(new VolatileMemoryStore());
kernelBuilder.WithMemoryStorage(new RedisMemoryStore("localhost:6379"));
var kernel = kernelBuilder.Build();
var collectionName = "Products";
await using var fs = File.OpenRead("text-sample.json");
var list = await JsonSerializer.DeserializeAsync<Product[]>(fs);
Guard.NotNull(list);
foreach (var product in list)
{
    await kernel.Memory.SaveInformationAsync(collectionName, product.Description, product.Title, product.Description, product.Category);
}


file sealed class Product
{
    [JsonPropertyName("id")]
    public required string Id { get; set; }
    
    [JsonPropertyName("category")]
    public required string Category { get; set; }
    
    [JsonPropertyName("title")]
    public required string Title { get; set; }
    
    [JsonPropertyName("content")]
    public required string Description { get; set; }
}

Running on a console targeted at net8.0 and with .NET 8 RC1 SDK

Expected behavior

success without exception

Screenshots

image

Platform

  • OS: Windows
  • IDE: VS Code
  • Language: C#
  • Source:
<PackageVersion Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.Memory.Redis" Version="0.24.230918.1-preview" />

Additional context

Without exception when using the memory storage such as VolatileMemoryStore

workaround solution: add a reference for Microsoft.Bcl.AsyncInterfaces

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codetriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions