Co jest nie tak z następującym kodem? Nie widzę przyczyny błędu wymienionego poniżej. Używam Mono, czy może to być błąd w Mono i czy będzie on kompilowany bez błędów w VStudio?Brak konwertowania parametrów boksu lub typu dla parametru ogólnego Typ z Mono
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;
}
}
Otrzymuję błąd kompilacji:
…/ClientFactory.cs(14,14): Error CS0314: The type `T' cannot be used as type parameter `T' in the generic type or method `….ClientFactory.CreateClient(string, string)'. There is no boxing or type parameter conversion from `T' to `System.ServiceModel.ClientBase' (CS0314)
skopiowane kod do nowego VC# 2010 projektu, zmienił '/ * do rzeczy * /' na 'klienta = default (T); 'i zastąpił dwa ustawienia' '". Kompiluje dobrze, bez błędu kompilatora. – dtb
Czy to może być błąd w Mono? – knittl
Którą wersję 'dmcs' używasz? – dtb