Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddDaprClient incompatible with keyed services #1235

Closed
onionhammer opened this issue Feb 13, 2024 · 9 comments · Fixed by #1238
Closed

AddDaprClient incompatible with keyed services #1235

onionhammer opened this issue Feb 13, 2024 · 9 comments · Fixed by #1238
Assignees
Labels
kind/bug Something isn't working P1
Milestone

Comments

@onionhammer
Copy link
Contributor

onionhammer commented Feb 13, 2024

Expected Behavior

When adding dapr client to service builder, this should not error

https://weblogs.asp.net/ricardoperes/net-8-dependency-injection-changes-keyed-services

// Add dapr client
builder.Services.AddDaprClient(client =>
{
    client.UseJsonSerializationOptions(JsonExtensions.JsonOptions);
});

Actual Behavior

When adding dapr to your serviceBuilder, if there are keyed services present, adding dapr fils with exception:

Unhandled exception. System.InvalidOperationException: This service descriptor is keyed. Your service provider may not support keyed services.

Steps to Reproduce the Problem

Add a dapr client to an application with keyed services defined, i.e. with Orleans:

builder.Host.UseOrleans(siloBuilder =>
{
    siloBuilder.AddActivityPropagation();
});
@onionhammer onionhammer added the kind/bug Something isn't working label Feb 13, 2024
@onionhammer onionhammer changed the title AddDapr incompatible with keyed services AddDaprClient incompatible with keyed services Feb 13, 2024
@artyom-p
Copy link

Same here, related to this issue.

image

@Sen-Gupta
Copy link

builder.AddServiceDefaults();
builder.Services.AddDaprClient();

System.InvalidOperationException
HResult=0x80131509
Message=This service descriptor is keyed. Your service provider may not support keyed services.
Source=Microsoft.Extensions.DependencyInjection.Abstractions
StackTrace:
at Microsoft.Extensions.DependencyInjection.ServiceDescriptor.ThrowKeyedDescriptor()
at Microsoft.Extensions.DependencyInjection.ServiceDescriptor.get_ImplementationType()
at Microsoft.Extensions.DependencyInjection.DaprServiceCollectionExtensions.<>c.b__0_0(ServiceDescriptor s)
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at Microsoft.Extensions.DependencyInjection.DaprServiceCollectionExtensions.AddDaprClient(IServiceCollection services, Action`1 configure)
at Insights.Worker.Manager.Program.Main(String[] args) in D:\Trade\InsightsOnDaprAspire\src\Workers\Manager\Program.cs:line 15

@onionhammer
Copy link
Contributor Author

For the contributors, here's a PR that addresses this in Microsoft.Identity.Web, for reference:

AzureAD/microsoft-identity-web#2676

@rliberoff
Copy link

rliberoff commented Feb 15, 2024

Guys!

We really need this for .NET Aspire. Do you have any update when We can expect to have this fixed?

Thank you!

@Sen-Gupta
Copy link

Sen-Gupta commented Feb 15, 2024 via email

@rliberoff
Copy link

Thank you @Sen-Gupta.

The issue is not with AddDapr but with AddDaprClient.

This happens with the newest .NET Aspire Preview 3.

@Sen-Gupta
Copy link

Sen-Gupta commented Feb 15, 2024 via email

@rliberoff
Copy link

From further investigation, we found out that the offending dependency is with library Microsoft.Extensions.Http.Resilience when updated from version 8.1.0 to 8.2.0. Hope it helps.

@Sen-Gupta
Copy link

@rliberoff

Double Confirmation!

That's correct. I did upgrade Microsoft.Extensions.Http.Resilience to 8.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working P1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants