Что не так со следующим кодом? Я не вижу причины указанной ниже ошибки. Я использую Mono, может ли это быть ошибкой в Mono, и будет ли он компилироваться без ошибок в VStudio?
public static class ClientFactory {
public static T CreateClient<T, I>()
/* error here */
where T : ClientBase<I>, I
where I : class {
return CreateClient<T, I>(null, null);
}
public static T CreateClient<T, I>(string endpointConfigurationName)
/* error here */
where T : ClientBase<I>, I
where I : class {
return CreateClient<T, I>(endpointConfigurationName, null);
}
public static T CreateClient<T, I>(string endpointConfigurationName, string remoteAddress)
/* error here */
where T : ClientBase<I>, I
where I : class {
return CreateClient<T, I>(endpointConfigurationName, remoteAddress, Settings.Default.UserName, Settings.Default.Password);
}
public static T CreateClient<T, I>(string endpointConfigurationName, string remoteAddress, string userName, string password)
/* NO error here, this method compiles fine */
where T : ClientBase<I>, I
where I : class {
T client;
/* get client instance */
/* do stuff with it */
return client;
}
}
Я получаю сообщение об ошибке компиляции:
… / ClientFactory.cs (14,14): Ошибка CS0314 : Тип `T 'не может использоваться как параметр типа` T' в универсальном типе или методе `… .ClientFactory.CreateClient (string, string) '. Отсутствует упаковка или преобразование параметров типа из `T 'в` System.ServiceModel.ClientBase' (CS0314)