Неоднозначная ссылка в WCF и клиентском приложении
Мне удалось воспроизвести одну из ошибок в тестовом проекте со структурой, аналогичной моему производственному коду. Он состоит из трех простых проектов:
Общий (библиотека классов):
namespace Common
{
public enum PrimaryColor
{
Red,
Green,
Blue
};
}
Библиотека (библиотека служб WCF), которая имеет ссылку на Common:
using Common;
namespace Library
{
[ServiceContract]
public interface ILibrary
{
[OperationContract]
PrimaryColor GetColor();
}
public class Library : ILibrary
{
public PrimaryColor GetColor()
{
return PrimaryColor.Red;
}
}
}
ClientApp (консольное приложение), в котором есть ссылка на Common и служебная ссылка на Library с именем & quot; LibraryServiceReference & quot ;:
using Common;
using ClientApp.LibraryServiceReference;
namespace ClientApp
{
class Program
{
static void Main(string[] args)
{
LibraryClient client = new LibraryClient("WSHttpBinding_ILibrary");
PrimaryColor color = client.GetColor();
}
}
}
Файлы app.config в ClientApp и Library создаются автоматически, и я не изменил их, и я не изменил конфигурацию по умолчанию для LibraryServiceReference в ClientApp.
Когда я компилирую это решение, я получаю следующие ошибки в проекте ClientApp:
Ошибка 1
'PrimaryColor' is an ambiguous reference between 'Common.PrimaryColor' and 'ClientApp.LibraryServiceReference.PrimaryColor'
Ошибка 2
Cannot implicitly convert type 'ClientApp.LibraryServiceReference.PrimaryColor' to 'Common.PrimaryColor'. An explicit conversion exists (are you missing a cast?)
пожалуйста, помогите мне исправить это.