{"record":{"id":"6a40c23d9ac4c4be","repo":"winsw/winsw","slug":"the-loaded-class-is-not-a-winsw-extension-classn","errorCode":null,"errorMessage":"The loaded class is not a WinSW extension: {className}. Type is {type}","messagePattern":"The loaded class is not a WinSW extension: (.+?)\\. Type is (.+?)","errorType":"exception","errorClass":"ExtensionException","httpStatus":null,"severity":"error","filePath":"src/WinSW.Core/Extensions/WinSWExtensionManager.cs","lineNumber":44,"sourceCode":"\n            try\n            {\n                var t = Type.GetType(className);\n                if (t is null)\n                {\n                    throw new ExtensionException(id, \"Class \" + className + \" does not exist\");\n                }\n\n                created = Activator.CreateInstance(t)!;\n            }\n            catch (Exception ex)\n            {\n                throw new ExtensionException(id, \"Cannot load the class by name: \" + className, ex);\n            }\n\n            if (!(created is IWinSWExtension extension))\n            {\n                throw new ExtensionException(id, \"The loaded class is not a WinSW extension: \" + className + \". Type is \" + created.GetType());\n            }\n\n            return extension;\n        }\n\n        /// <summary>\n        /// Notifies all extensions that the wrapper is being started.\n        /// They are supposed to run the initialization logic.\n        /// If any extensions fails, WinSW startup should be interrupted.\n        /// </summary>\n        /// <exception cref=\"Exception\">Start failure</exception>\n        public void FireOnWrapperStarted()\n        {\n            foreach (var ext in this.Extensions)\n            {\n                try\n                {\n                    ext.Value.OnWrapperStarted();","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/winsw/winsw/blob/1d0ee4a91bad596d5e7e9c360f2b39ef54674674/src/WinSW.Core/Extensions/WinSWExtensionManager.cs#L26-L62","documentation":"After successfully instantiating the configured type, CreateExtensionInstance checks whether it implements IWinSWExtension. If not, it throws ExtensionException naming the class and its actual type. The type loaded fine; it simply isn't a valid WinSW extension.","triggerScenarios":"className points to a class that exists and instantiates but does not implement IWinSWExtension — e.g. a utility class, a plain POCO, or a type implementing a different/older extension interface.","commonSituations":"Wrong class selected in config; extension author forgot to implement the interface; referencing an internal helper class; interface was renamed/moved across versions.","solutions":["Make the target class implement IWinSWExtension (and its members).","Point className at the class that actually is the extension entry point.","Rebuild against the current WinSW extension contract so the interface matches."],"exampleFix":"// before\npublic class MyExt { /* no IWinSWExtension */ }\n// after\npublic class MyExt : IWinSWExtension\n{\n    public void Configure(IWinSWExtensionDescriptor descriptor, XmlElement config) { }\n    public void OnWrapperStarted() { }\n    public void BeforeWrapperStopped() { }\n}","handlingStrategy":"type-guard","validationCode":"var t = Type.GetType(className);\nif (t is null) throw new InvalidOperationException(\"Type unresolved\");\nif (!typeof(IWinSWExtension).IsAssignableFrom(t)) throw new InvalidOperationException($\"{t} does not implement IWinSWExtension\");","typeGuard":"static bool IsWinSWExtension(string className) => Type.GetType(className) is { } t && typeof(IWinSWExtension).IsAssignableFrom(t);","tryCatchPattern":"try { manager.LoadExtension(id); }\ncatch (ExtensionException ex) when (ex.Message.Contains(\"not a WinSW extension\")) { /* implement IWinSWExtension or fix className */ }","preventionTips":["Implement the full IWinSWExtension contract in your extension class.","Point className at the real entry-point class.","Type-guard before referencing in config."],"tags":["extension","reflection","type-loading","winsw"],"backgroundTag":null,"analyzedSha":"1d0ee4a91bad596d5e7e9c360f2b39ef54674674","analyzedAt":"2026-08-13T15:26:09.332Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}