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
- Use the assembly-qualified name (Namespace.Type, AssemblyName) so Type.GetType can find it.
- Ensure the assembly containing the type is loaded, or use a type resolver that scans AppDomain/dependency context.
- Add [ForwardedType] forwarding or update persisted definitions to the new type name after renames.
- 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
- Persist typeof(X).AssemblyQualifiedName, never short names
- After package upgrades, scan stored definitions for stale type names
- Add ForwardedTypeAttribute when renaming types to keep old definitions loading
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
- Value cannot be null. (Parameter 'type')
- Type ' ' not found.
- Cannot deserialize to .
- Failed to deserialize
- Failed to convert an object of type
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)