egametang/ET · error
create config factory failed: {factoryType.FullName}
Error message
create config factory failed: {factoryType.FullName} What it means
Thrown by CreateConfigFactories when Activator.CreateInstance(factoryType) returns something that is NOT an IConfigFactory. The candidate type already passed the typeof(IConfigFactory).IsAssignableFrom filter (line 100), so in practice this throw means the instance was null — which Activator.CreateInstance returns only for nullable-value-type edge cases, or the constructor threw and was swallowed. More commonly it indicates a factory whose parameterless constructor is missing (Activator returns null for certain Nullable<T> scenarios) or a reflection/CLR quirk.
Source
Thrown at Packages/cn.etetet.loader/Scripts/Loader/Share/ConfigLoaderHelper.cs:114
{
continue;
}
if (!typeof(IConfigFactory).IsAssignableFrom(type))
{
continue;
}
factoryTypes.Add(type);
}
factoryTypes.Sort((left, right) => string.CompareOrdinal(left.FullName, right.FullName));
ConfigFactoryGroupCollection factories = new();
foreach (Type factoryType in factoryTypes)
{
if (Activator.CreateInstance(factoryType) is not IConfigFactory factory)
{
throw new Exception($"create config factory failed: {factoryType.FullName}");
}
factories.Add(GetConfigGroup(factoryType), factory);
}
return factories;
}
public static ASingleton LoadOneConfig(Type configType, ConfigFactoryGroupCollection configFactories, Dictionary<Type, IConfig> loadedConfigs)
{
ConfigProcessAttribute configProcessAttribute = configType.GetCustomAttributes(typeof(ConfigProcessAttribute), false)[0] as ConfigProcessAttribute;
if (configProcessAttribute.ConfigType != ConfigType.Code)
{
throw new Exception($"unsupported config type: {configProcessAttribute.ConfigType} {configType.FullName}");
}
IConfigFactory factory = GetConfigFactory(configType, configFactories);
object category = factory.Create();View on GitHub (pinned to 5cab01f7a8)
Solutions
- Ensure the factory is a class with a public parameterless constructor.
- If it must be a struct, verify Activator.CreateInstance boxes correctly under the target runtime (test on IL2CPP/AOT).
- Catch MissingMethodException separately to distinguish a missing constructor from this null-result case.
Example fix
// before — struct factory, Activator edge case
public struct MyFactory : IConfigFactory { ... }
// after — class with public parameterless ctor
public class MyFactory : IConfigFactory
{
public MyFactory() { }
public Type ConfigType => typeof(MyConfigCategory);
} Defensive patterns
Strategy: validation
Validate before calling
// Prefer classes with public parameterless ctors; assert at design time
if (factoryType.IsValueType || factoryType.GetConstructor(Type.EmptyTypes) == null)
Log.Error($"factory {factoryType.FullName} must be a class with a public parameterless ctor"); Type guard
static bool IsInstantiableFactory(Type t) =>
!t.IsAbstract && !t.IsInterface && !t.IsValueType
&& t.GetConstructor(Type.EmptyTypes) != null; Prevention
- Make config factories classes, not structs.
- Ensure a public parameterless constructor on every factory.
- Test factory instantiation under the target runtime (IL2CPP/AOT), not just editor/mono.
When it happens
Trigger: A type implements IConfigFactory, is non-abstract and concrete, but its instantiation via Activator.CreateInstance does not yield a non-null IConfigFactory. Typically a missing public parameterless constructor causes a MissingMethodException earlier, so this specific throw points at a value-type/Nullable instantiation oddity or a constructor that returns null unexpectedly.
Common situations: A factory is a struct (ValueType) implementing IConfigFactory where the boxed 'is not IConfigFactory' pattern misbehaves; a factory whose constructor logic leaves it in an unusable state; an AOT/IL2CPP stripping issue removing the constructor.
Related errors
- config factory target is null: {factory.GetType().FullName}
- config factory not found: {configType.FullName}
- config group is empty: {factory.GetType().FullName}
- duplicate config factory: {factory.ConfigType.FullName} grou
- config create failed: {configType.FullName}
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/431928a7f732ce6e.
Report an issue: GitHub.