2

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());
        }
    }
}
4

1 に答える 1

3

アセンブリ参照に循環参照がある可能性があるため、メソッド呼び出しがあいまいになります。

質問のコメントUserControlsでそのアセンブリから使用したことを説明したように、VS デザイナーは、VS ツールボックスからUserControl'sを使用するときに時々発生するため、含まれているアセンブリの参照をそれ自体に追加した可能性があります。UserControl

于 2015-03-09T09:46:12.910 に答える