pardeike/Harmony · error · NotSupportedException

Unsupported callsite element

Error message

Unsupported callsite element: {etype}

What it means

InlineSignatureParser.ImportCallSite decodes callsite signature element types; the default branch of its element-type switch throws NotSupportedException for any MetadataType it does not explicitly handle, meaning the callsite uses an element kind the parser does not support.

Solutions

  1. Remove custom modifiers or exotic element types from the callsite signature you are trying to import
  2. Emit the signature against a simplified equivalent type without modreq/modopt
  3. Upgrade Harmony — the parser's supported element set grows across versions
  4. Manually decode the signature blob to identify the unsupported element type and work around it with a wrapper method

Example fix

// before
importing callsite whose param has modreq(IsVolatile)
// after
call the method directly or via a delegate with a plain (unmodified) signature
Defensive patterns

Strategy: try-catch

Try / catch

try { var callSite = parser.ImportCallSite(module); }
catch (NotSupportedException ex) when (ex.Message.StartsWith("Unsupported callsite element")) { /* strip exotic element types or use a wrapper */ }

Prevention

When it happens

Trigger: ImportCallSite reading an element type not covered by its cases (primitives, string, etc.) — e.g. MODIFIER (CMOD_OPT/CMOD_REQD), SENTINEL, typed references, or other exotic metadata element types in the callsite blob.

Common situations: Signatures containing custom modifiers (modreq/modopt) or vararg sentinels; hand-written IL with rarely used element types; assemblies produced by unusual compilers or IL rewriters.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of pardeike/Harmony@e7872dc170 (2026-09-15). Data as JSON: /api/errors/4eea8492d921357c. Report an issue: GitHub.

Appendix: source

Thrown at Harmony/Internal/InlineSignatureParser.cs:254

						return typeof(uint);

					case MetadataType.Int64:
						return typeof(long);

					case MetadataType.UInt64:
						return typeof(ulong);

					case MetadataType.Single:
						return typeof(float);

					case MetadataType.Double:
						return typeof(double);

					case MetadataType.String:
						return typeof(string);

					default:
						throw new NotSupportedException($"Unsupported callsite element: {etype}");
				}
			}
		}

	}
}

View on GitHub (pinned to e7872dc170)