SMAPI assembly load fails if constructor has argument type from secondary DLL
Pathoschild opened this issue ยท 2 comments
If a class in the main mod DLL takes an argument whose type is defined in a secondary DLL, the following error occurs:
[15:39:06 ERROR SMAPI] Couldn't load mod for manifest 'C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley\Mods\SmapiResolvingTest\manifest.json': an error occurred while preprocessing 'SmapiResolvingTest.dll'.
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Dependent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
at Mono.Cecil.TypeReference.Resolve()
at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypeDefs()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__1_0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
at Mono.Cecil.AssemblyDefinition.Write(Stream stream)
at StardewModdingAPI.Framework.ModAssemblyLoader.ProcessAssemblyUnlessCached(String assemblyPath) in D:\source\_Stardew\SMAPI\src\StardewModdingAPI\Framework\ModAssemblyLoader.cs:line 76
at StardewModdingAPI.Program.LoadMods() in D:\source\_Stardew\SMAPI\src\StardewModdingAPI\Program.cs:line 469
See attached minimal project which reproduces the issue. Reported by @Igorious.
Fixed in develop
via #229 for the upcoming 1.8 release. Pending confirmation.
Confirmed fixed by @Igorious. (Thanks!)