¿Qué pasa con el siguiente código? No puedo ver el motivo del error mencionado a continuación. Estoy usando Mono, ¿podría ser un error en Mono y se compilará sin errores en VStudio?Sin conversión de parámetros de tipo de cuadro o tipo para el parámetro Tipo genérico con 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;
}
}
estoy recibiendo el error de compilación:
…/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)
He copiado el código para un nuevo proyecto VC# 2010, cambió '/ * hacer cosas * /' a 'cliente = predeterminado (T); 'y reemplazado las dos configuraciones con' "" '. Compila bien, sin error del compilador. – dtb
¿Podría ser esto un error en Mono? – knittl
¿Qué versión de 'dmcs' estás usando? – dtb