{"record":{"id":"3b8cf7edef045f10","repo":"PrismLibrary/Prism","slug":"moduleinfo","errorCode":null,"errorMessage":"moduleInfo","messagePattern":"moduleInfo","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Modularity/LoadModuleCompletedEventArgs.cs","lineNumber":21,"sourceCode":"using System;\n\nnamespace Prism.Modularity\n{\n    /// <summary>\n    /// Provides completion information after a module is loaded, or fails to load.\n    /// </summary>\n    public class LoadModuleCompletedEventArgs : EventArgs\n    {\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"LoadModuleCompletedEventArgs\"/> class.\n        /// </summary>\n        /// <param name=\"moduleInfo\">The module info.</param>\n        /// <param name=\"error\">Any error that occurred during the call.</param>\n        public LoadModuleCompletedEventArgs(IModuleInfo moduleInfo, Exception error)\n        {\n            if (moduleInfo == null)\n            {\n                throw new ArgumentNullException(nameof(moduleInfo));\n            }\n\n            this.ModuleInfo = moduleInfo;\n            this.Error = error;\n        }\n\n        /// <summary>\n        /// Gets the module info.\n        /// </summary>\n        /// <value>The module info.</value>\n        public IModuleInfo ModuleInfo { get; private set; }\n\n        /// <summary>\n        /// Gets any error that occurred\n        /// </summary>\n        /// <value>The exception if an error occurred; otherwise null.</value>\n        public Exception Error { get; private set; }\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Modularity/LoadModuleCompletedEventArgs.cs#L3-L39","documentation":"The LoadModuleCompletedEventArgs constructor throws ArgumentNullException when the moduleInfo parameter is null. Prism requires every load-completed event argument to carry a non-null IModuleInfo; the optional error parameter is separate. This is a fail-fast guard so downstream event handlers never need to null-check ModuleInfo.","triggerScenarios":"Directly calling new LoadModuleCompletedEventArgs(null, someException) instead of relying on the module loading service (ModuleInitializer/ModuleManager) to construct the args.","commonSituations":"Custom IModuleManager implementations, unit tests that build the event args by hand, or reflection-based wrappers that pass a null module record after a failed module load lookup.","solutions":["Pass the actual IModuleInfo instance that was being loaded; on failure still supply it with the Exception in the error parameter rather than null.","If you only have a module name, resolve the IModuleInfo from the catalog before raising LoadModuleCompleted.","In tests, construct a stub IModuleInfo (e.g. new ModuleInfo(\"TestModule\")) instead of passing null."],"exampleFix":"// before\nvar args = new LoadModuleCompletedEventArgs(null, ex);\n// after\nvar moduleInfo = catalog.Modules.FirstOrDefault(m => m.ModuleName == moduleName) ?? new ModuleInfo(moduleName);\nvar args = new LoadModuleCompletedEventArgs(moduleInfo, ex);","handlingStrategy":"validation","validationCode":"if (moduleInfo == null) throw new InvalidOperationException(\"Cannot raise LoadModuleCompleted without an IModuleInfo\");\nvar args = new LoadModuleCompletedEventArgs(moduleInfo, error);","typeGuard":"bool IsValidArgs(LoadModuleCompletedEventArgs a) => a?.ModuleInfo != null;","tryCatchPattern":"try\n{\n    var args = new LoadModuleCompletedEventArgs(moduleInfo, error);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == nameof(moduleInfo))\n{\n    logger.LogError(ex, \"Attempted to raise load-completed with null module info\");\n}","preventionTips":["Always construct event args through the module manager rather than by hand","Pass the module even on failure and put the failure in the Error property","Null-check sources of IModuleInfo (catalog lookups) before raising events"],"tags":["argumentnull","modularity","prism"],"backgroundTag":"null-argument","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}