elsa-workflows/elsa-core · error · InvalidOperationException

Type not found.

Error message

Type {typeName} not found.

What it means

TypeHelper.GetLatestType resolves a type by assembly-qualified name and follows ForwardedTypeAttribute to the current replacement type. If Type.GetType returns null (name not found) it throws this InvalidOperationException with the original type name.

Solutions

  1. Use the assembly-qualified name (Namespace.Type, AssemblyName) so Type.GetType can find it.
  2. Ensure the assembly containing the type is loaded, or use a type resolver that scans AppDomain/dependency context.
  3. Add [ForwardedType] forwarding or update persisted definitions to the new type name after renames.
  4. Verify the exact stored name with typeof(X).AssemblyQualifiedName and compare.

Example fix

// before
TypeHelper.GetLatestType("Elsa.MyApp.OldActivity");
// after
TypeHelper.GetLatestType("Elsa.MyApp.NewActivity, Elsa.MyApp");
Defensive patterns

Strategy: validation

Validate before calling

var type = Type.GetType(typeName, throwOnError: false);
if (type == null)
    throw new InvalidOperationException($"Type '{typeName}' is not resolvable; use an assembly-qualified name and ensure the assembly is loaded.");

Type guard

bool IsResolvableTypeName(string? typeName) => !string.IsNullOrWhiteSpace(typeName) && Type.GetType(typeName, throwOnError: false) != null;

Try / catch

try { var type = TypeHelper.GetLatestType(typeName); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Type ") && ex.Message.EndsWith(" not found.")) { logger.LogError(ex, "Unknown or renamed type: {TypeName}", typeName); }

Prevention

When it happens

Trigger: Calling GetLatestType with a type name that is misspelled, not assembly-qualified, belongs to an assembly not loaded, or was renamed/moved in a newer package version.

Common situations: Stored workflow definitions persisting old type names after a package upgrade; types in assemblies not yet loaded (Type.GetType only searches the executing assembly and mscorlib for partial names); typos in configuration.

Related errors


AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/2255674fdc0c5117. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Common/Helpers/TypeHelper.cs:11

using System.Reflection;

namespace Elsa.Common.Helpers;

public static class TypeHelper
{
    public static Type GetLatestType(string typeName)
    {
        var type = Type.GetType(typeName);
        var deprecatedByTypeAttribute = type?.GetCustomAttribute<ForwardedTypeAttribute>();
        return deprecatedByTypeAttribute?.NewType ?? type ?? throw new InvalidOperationException($"Type {typeName} not found.");
    }
}

View on GitHub (pinned to fe9217bdfa)