private static void RegisterConVars(Assembly assembly) { List <BaseConVar> customVars = new List <BaseConVar>(); foreach (Type type in assembly.GetTypes()) { foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) { if (field.FieldType.IsSubclassOf(typeof(BaseConVar))) { if (field.IsStatic) { console.InvokeMethod("RegisterConVarInternal", (BaseConVar)field.GetValue(null)); //console.RegisterConVarInternal((BaseConVar)field.GetValue(null));//This line fails on Release. customVars.Add((BaseConVar)field.GetValue(null)); } else if (CustomAttributeExtensions.GetCustomAttribute <CompilerGeneratedAttribute>(type) == null) { Debug.LogErrorFormat("ConVar defined as {0} in {1}. {2} could not be registered. ConVars must be static fields.", type.Name, assembly.FullName, field.Name); } } } } foreach (BaseConVar baseConVar in customVars) { if ((baseConVar.flags & ConVarFlags.Engine) != ConVarFlags.None) { baseConVar.defaultValue = baseConVar.GetString(); } else if (baseConVar.defaultValue != null) { baseConVar.SetString(baseConVar.defaultValue); } } }