assets.bodies name resolution fails for creatures with no parameterless constructor (MissingMethodException) #40

Closed
opened 2026-11-25 17:05:52 -06:00 by wtclaude · 0 comments
Member

Split out of #39 ("Related findings"), which asked for this to be its own issue.

Summary

During an Asset Bridge catalogue / assets.bodies import, body→name resolution throws
MissingMethodException for every creature type whose only public constructor is the
[Constructable] one (args) — there is no parameterless constructor to invoke.

Observed on the live Linux/Mono shard, same import as #39:

[Bridge] assets.bodies: greatape: MissingMethodException: Default constructor not found for type Server.Mobiles.GreatApe

…and the same for Navrey, TribeChieftan, TribeShaman, TribeWarrior. There are
almost certainly more types in this class than the five that happened to be touched by
that one import.

Root cause

overlay/Scripts/Custom/Bridge/BridgeBodies.cs:215 resolves a name to its body id by
instantiating the mobile and reading creature.Body.BodyID:

creature = Activator.CreateInstance(type) as BaseCreature;
...
body = creature.Body.BodyID;

Activator.CreateInstance(type) with no args needs a public parameterless constructor.
Many ServUO creatures declare only public GreatApe() : base(...) marked [Constructable]
(plus the protected (Serial) deserialization ctor), so there is no parameterless ctor and
the call throws. The surrounding try/catch already logs the line and sets status = "failed" (so the import does not crash), but these creatures get no body→name mapping —
their names never resolve through this path.

This is unrelated to GDI+ (#39) and independent of platform — it would throw on Windows too;
it simply surfaced during the same Linux import.

Possible directions (to be scoped before building)

  • Instantiate via the [Constructable] constructor using sensible/default arguments, or the
    constructor with the fewest parameters, instead of requiring a parameterless one.
  • Use FormatterServices.GetUninitializedObject(type) to get an instance without running a
    constructor, then read Body — but Body is usually assigned in the constructor, so an
    uninitialized object may report body 0. Needs verification per type.
  • Resolve body ids from the type's source/metadata rather than by instantiation (the
    approach uofiddler-client-extraction notes for the atlas).

Each has trade-offs (side effects of running a real constructor vs. an uninitialized object
that never sets Body); pick one with design approval. Low urgency — the failure is already
caught and logged, it only costs name resolution for the affected creatures.


Split out of #39 ("Related findings"), which asked for this to be its own issue. ## Summary During an Asset Bridge catalogue / `assets.bodies` import, body→name resolution throws `MissingMethodException` for every creature type whose only public constructor is the `[Constructable]` one (args) — there is no parameterless constructor to invoke. Observed on the live Linux/Mono shard, same import as #39: ``` [Bridge] assets.bodies: greatape: MissingMethodException: Default constructor not found for type Server.Mobiles.GreatApe ``` …and the same for `Navrey`, `TribeChieftan`, `TribeShaman`, `TribeWarrior`. There are almost certainly more types in this class than the five that happened to be touched by that one import. ## Root cause `overlay/Scripts/Custom/Bridge/BridgeBodies.cs:215` resolves a name to its body id by instantiating the mobile and reading `creature.Body.BodyID`: ```csharp creature = Activator.CreateInstance(type) as BaseCreature; ... body = creature.Body.BodyID; ``` `Activator.CreateInstance(type)` with no args needs a public parameterless constructor. Many ServUO creatures declare only `public GreatApe() : base(...)` marked `[Constructable]` (plus the protected `(Serial)` deserialization ctor), so there is no parameterless ctor and the call throws. The surrounding `try/catch` already logs the line and sets `status = "failed"` (so the import does not crash), but these creatures get **no** body→name mapping — their names never resolve through this path. This is unrelated to GDI+ (#39) and independent of platform — it would throw on Windows too; it simply surfaced during the same Linux import. ## Possible directions (to be scoped before building) - Instantiate via the `[Constructable]` constructor using sensible/default arguments, or the constructor with the fewest parameters, instead of requiring a parameterless one. - Use `FormatterServices.GetUninitializedObject(type)` to get an instance without running a constructor, then read `Body` — but `Body` is usually assigned *in* the constructor, so an uninitialized object may report body 0. Needs verification per type. - Resolve body ids from the type's source/metadata rather than by instantiation (the approach `uofiddler-client-extraction` notes for the atlas). Each has trade-offs (side effects of running a real constructor vs. an uninitialized object that never sets `Body`); pick one with design approval. Low urgency — the failure is already caught and logged, it only costs name resolution for the affected creatures. ---
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: RunicGateway/servuo-plugins#40
No description provided.