{"record":{"id":"9783225bead7cb85","repo":"OrchardCMS/OrchardCore","slug":"the-specified-activity-type-is-not-registered","errorCode":null,"errorMessage":"The specified activity type is not registered.","messagePattern":"The specified activity type is not registered\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Workflows.Abstractions/Options/WorkflowOptions.cs","lineNumber":40,"sourceCode":"        {\n            if (driverType != null)\n            {\n                value.DriverTypes.Add(driverType);\n            }\n        }\n        else\n        {\n            ActivityDictionary.Add(activityType, new ActivityRegistration(activityType, driverType));\n        }\n\n        return this;\n    }\n\n    public WorkflowOptions UnregisterActivityType(Type activityType)\n    {\n        if (!ActivityDictionary.ContainsKey(activityType))\n        {\n            throw new InvalidOperationException(\"The specified activity type is not registered.\");\n        }\n\n        ActivityDictionary.Remove(activityType);\n        return this;\n    }\n\n    public bool IsActivityRegistered(Type activityType)\n    {\n        return ActivityDictionary.ContainsKey(activityType);\n    }\n}\n\npublic static class WorkflowOptionsExtensions\n{\n    public static WorkflowOptions RegisterActivityType<T>(this WorkflowOptions options)\n    {\n        return options.RegisterActivity(typeof(T));\n    }","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Workflows.Abstractions/Options/WorkflowOptions.cs#L22-L58","documentation":"Thrown by WorkflowOptions.UnregisterActivityType when the given activity Type is not present in the ActivityDictionary. The options container tracks registered workflow activity types, and unregistering an unknown type is treated as a programming error.","triggerScenarios":"Calling UnregisterActivityType for a type that was never registered via AddActivityType, or calling it twice; using a derived/base type mismatch since lookup is by exact Type key.","commonSituations":"Module shutdown/teardown code that unregisters activities possibly never added; feature disable ordering where another module already unregistered the type; typos or refactors renaming activity classes.","solutions":["Guard with WorkflowOptions' dictionary state (or a ContainsKey check via the same options instance) before unregistering.","Only unregister types your own module registered, in the reverse order of registration.","Catch InvalidOperationException and ignore the already-unregistered case.","Refactor registration bookkeeping to be idempotent."],"exampleFix":"// before\noptions.UnregisterActivityType(typeof(MyActivity));\n// after\nif (options.ActivityDictionary.ContainsKey(typeof(MyActivity))) { options.UnregisterActivityType(typeof(MyActivity)); }","handlingStrategy":"validation","validationCode":"if (options.ActivityDictionary.ContainsKey(typeof(MyActivity))) { options.UnregisterActivityType(typeof(MyActivity)); }","typeGuard":"bool IsRegistered(WorkflowOptions o, Type t) => o.ActivityDictionary.ContainsKey(t);","tryCatchPattern":"try { options.UnregisterActivityType(typeof(MyActivity)); }\ncatch (InvalidOperationException) { /* already unregistered; ignore */ }","preventionTips":["Track what your module registered and unregister exactly that","Make registration/unregistration pairs idempotent","Check module disable ordering across dependent features","Avoid unregistering base/derived types interchangeably"],"tags":["workflows","registration","options"],"backgroundTag":"invalid-state-transition","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}