Skip to content

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

Closed

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

Activity

  1. added
    .NET
    on Sep 24, 2023
  2. changed the title [-]Could not load file or assembly `Microsoft.Bcl.AsyncInterfaces` exception[/-] [+].Net: Could not load file or assembly `Microsoft.Bcl.AsyncInterfaces` exception[/+] on Sep 24, 2023
  3. added a commit that references this issue on Sep 29, 2023
    8c07296
  4. added a commit that references this issue on Nov 1, 2023
    862c712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETtriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions