Skip to content

AmbiguousMatchException #1028

@eValker

Description

@eValker

Hi,

the latest change in Grpc.AspNet causes an AmbiguousMatchException in the MagicOnion library. Specifically, this is related to the change introduced in version:
https://github.com/grpc/grpc-dotnet/releases/tag/v2.76.0

More precisely, it seems to be caused by this PR:
grpc/grpc-dotnet#2634

In this PR, a new overload of the MapGrpcService method was added:

public static GrpcServiceEndpointConventionBuilder MapGrpcService(this IEndpointRouteBuilder builder, ServerServiceDefinition serviceDefinition)

public static GrpcServiceEndpointConventionBuilder MapGrpcService(this IEndpointRouteBuilder builder, Func<IServiceProvider, ServerServiceDefinition> getServiceDefinition)

The problem is located in MagicOnionGrpcServiceMappingContext, in the Map(Type) method.

public void Map(Type t)
    {
        VerifyServiceType(t);

        innerBuilders.Add(new MagicOnionServiceEndpointConventionBuilder((GrpcServiceEndpointConventionBuilder)typeof(GrpcEndpointRouteBuilderExtensions)
            .GetMethod(nameof(GrpcEndpointRouteBuilderExtensions.MapGrpcService))!
            .MakeGenericMethod(t)
            .Invoke(null, [builder])!));
    }

There is an attempt to retrieve the MapGrpcService method with IEndpointRouteBuilder parameter via reflection; however, there are now two such methods.

I’m not sure whether there is any workaround that can be applied to bypass the issue without making changes to the library itself.

Kind regards,
Valker

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions