SoloCodigo
CLR: .Net / Mono / Boo / Otros CLR => C# => Mensaje iniciado por: Sined99 en Jueves 20 de Octubre de 2011, 09:11
-
Hola a tod@s!
Os comento tengo una aplicacion en la que tengo un form padre y un form hijo, y tengo una clase static, resulta que cuando ejecuto me sale la excepcion typeInitializationException en una linea del form del padre
datagridview1.Columns[0].HeaderText = Variables_Globales.TEXTO_CODIGO;
La clase static solo tiene un par de atributos
static class Variables_Globales
{
public static string TEXTO_CODIGO = "Code";
...
}
¿Alguien me puede echar una mano?
Muchas gracias, un saludo.
-
Hola,
He resuelto el problema pero sinceramente no se muy bien porque se produce, si alguien sabe el porque y puede arrojar un poco de luz lo agradeceria. Os comento, el error estaba en la siguiente linea de la clase static
public static string HORA= string.Format(FORMATO_HORA, DateTime.Now);
public static string FORMATO_HORA="{0:HH:mm:ss tt}";
Lo he solucionado cambiando este codigo por:
public static string FORMATO_HORA
{
get { return "{0:HH:mm:ss tt}"; }
}
public static string HORA
{
get { return string.Format(Variables_Globales.FORMATO_HORA, DateTime.Now); }
}