diff --git a/Mirror/Weaver/Processors/SyncListProcessor.cs b/Mirror/Weaver/Processors/SyncListProcessor.cs index c3169a1a0..1f9843224 100644 --- a/Mirror/Weaver/Processors/SyncListProcessor.cs +++ b/Mirror/Weaver/Processors/SyncListProcessor.cs @@ -1,4 +1,5 @@ // SyncList code +using System; using System.Linq; using Mono.Cecil; using Mono.Cecil.Cil; @@ -27,7 +28,17 @@ public static void GenerateSyncListInstanceInitializer(ILProcessor ctorWorker, F // Not initialized by the user in the field definition, e.g: // public SyncListInt Foo; - var listCtor = Weaver.scriptDef.MainModule.ImportReference(fd.FieldType.Resolve().Methods.First(x => x.Name == ".ctor" && !x.HasParameters)); + MethodReference listCtor; + try + { + listCtor = Weaver.scriptDef.MainModule.ImportReference(fd.FieldType.Resolve().Methods.First(x => x.Name == ".ctor" && !x.HasParameters)); + } + catch (Exception) + { + Weaver.fail = true; + Log.Error($"Missing parameter-less constructor for: {fd.FieldType.Name}"); + return; + } ctorWorker.Append(ctorWorker.Create(OpCodes.Ldarg_0)); ctorWorker.Append(ctorWorker.Create(OpCodes.Newobj, listCtor));