{"record":{"id":"fbcc44184445a448","repo":"elsa-workflows/elsa-core","slug":"type-stringvalue-not-found","errorCode":null,"errorMessage":"Type '{stringValue}' not found.","messagePattern":"Type '(.+?)' not found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Common/Serialization/TypeTypeConverter.cs","lineNumber":21,"sourceCode":"using JetBrains.Annotations;\n\nnamespace Elsa.Common.Serialization;\n\n[PublicAPI]\npublic class TypeTypeConverter : TypeConverter\n{\n    public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)\n    {\n        return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);\n    }\n\n    public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)\n    {\n        if (value is string stringValue)\n        {\n            if (TypeAliasRegistry.GetType(stringValue) is { } type)\n                return type;\n            return Type.GetType(stringValue) ?? throw new InvalidOperationException($\"Type '{stringValue}' not found.\");\n        }\n        return base.ConvertFrom(context, culture, value);\n    }\n\n    public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)\n    {\n        return destinationType == typeof(string) || base.CanConvertTo(context, destinationType);\n    }\n\n    public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)\n    {\n        if (destinationType == typeof(string) && value is Type type)\n        {\n            if (TypeAliasRegistry.TypeAliases.FirstOrDefault(x => x.Value == type).Key is { } alias)\n                return alias;\n            return type.AssemblyQualifiedName;\n        }\n        return base.ConvertTo(context, culture, value, destinationType);","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Common/Serialization/TypeTypeConverter.cs#L3-L39","documentation":"TypeTypeConverter converts a string (from e.g. TypeConverter-based binding or property grids) into a Type. It first tries the TypeAliasRegistry, then Type.GetType; if both fail it throws InvalidOperationException because the requested type cannot be located.","triggerScenarios":"Calling TypeDescriptor.GetConverter(typeof(Type)).ConvertFrom(\"Some.Type.Name\") (or assigning a string to a Type property through such a converter) with a string that is neither a registered type alias nor an assembly-qualified type name resolvable by Type.GetType.","commonSituations":"Passing a short type name like \"MyActivity\" instead of an assembly-qualified name; typo in namespace; the assembly containing the type is not loaded into the AppDomain; alias not registered in TypeAliasRegistry.","solutions":["Use the assembly-qualified type name (e.g. \"My.Namespace.MyType, My.Assembly, Version=...\")","Register the alias with the TypeAliasRegistry so the short name resolves","Ensure the assembly containing the type is loaded before conversion","Fix typos in the namespace/type name"],"exampleFix":"// before\nvar t = (Type)TypeDescriptor.GetConverter(typeof(Type)).ConvertFrom(\"MyActivity\");\n// after\nvar t = (Type)TypeDescriptor.GetConverter(typeof(Type)).ConvertFrom(\"MyApp.Activities.MyActivity, MyApp\");","handlingStrategy":"validation","validationCode":"var resolved = TypeAliasRegistry.GetType(name) ?? Type.GetType(name);\nif (resolved is null) throw new ArgumentException($\"Type '{name}' is not resolvable.\", nameof(name));","typeGuard":"bool IsResolvableType(string name) => TypeAliasRegistry.GetType(name) is not null || Type.GetType(name, throwOnError: false) is not null;","tryCatchPattern":"try { return (Type)converter.ConvertFrom(name); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Type '\") && ex.Message.EndsWith(\"' not found.\"))\n{ logger.LogWarning(\"Unknown type name {Name}\", name); return null; }","preventionTips":["Use assembly-qualified names for Type conversions","Register short aliases in TypeAliasRegistry","Ensure referenced assemblies are loaded before conversion","Add unit tests resolving all configured type names"],"tags":["type-conversion","reflection","type-resolution"],"backgroundTag":"class-not-found","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}