Thomas Andreè Wang
Thomas Andreè Wang

Reputation: 3429

'The call is ambiguous between the following methods or properties' on identical paths

I'm having a strange error with Umbraco/uCommerce, I built a support library and suddenly I'm getting a strange error preventing compilation.

Error 9 The call is ambiguous between the following methods or properties: 'uCommerce_Boilerplate.Web.Controllers.ExtensionFunctions.ToDescription(System.Enum)' and 'uCommerce_Boilerplate.Web.Controllers.ExtensionFunctions.ToDescription(System.Enum)'

I have one file that contains several features, and this is the snippet prompting the error.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using UCommerce;
using UCommerce.EntitiesV2;
using UCommerce.Infrastructure;
using UCommerce.Transactions;
using UCommerce.Transactions.Payments;
using UCommerce.Transactions.Payments.Dibs;

namespace uCommerce_Boilerplate.Web.Controllers
{
    public static class ExtensionFunctions
    {
        public static string ToDescription(this Enum value)
        {
            var da = (DescriptionAttribute[])(value.GetType().GetField(value.ToString())).GetCustomAttributes(typeof(DescriptionAttribute), false);
            return da.Length > 0 ? da[0].Description : value.ToString();
        }
    }
    public static class SupportLib
    {
        public enum MethodName
        {
            [Description("Invoice")] Invoice = 1,
        }
        public static void RunOrder(MethodName methodName = MethodName.Invoice)
        {
            // The methodName.ToDescription() is throwing the error
            PaymentMethod method = getPaymentMethod(methodName.ToDescription());
        }
    }
}

Upvotes: 2

Views: 3175

Answers (1)

toadflakz
toadflakz

Reputation: 7934

You may have a circular reference in your assembly references which is why the method call is suddenly ambiguous.

As you described in the question comments you have used UserControls from that assembly within itself, the VS Designer might have added a reference of the UserControl's containing assembly to itself as this is what sometimes happens when you use a UserControl from the VS Toolbox.

Upvotes: 3

Related Questions