{"record":{"id":"0166daba25462b74","repo":"dotnet/wpf","slug":"schema-not-found","errorCode":null,"errorMessage":"Schema not found","messagePattern":"Schema not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/ResourceGenerator.cs","lineNumber":191,"sourceCode":"            {\n                Usage();\n                resourceModel = null;\n                return;\n            }\n\n\n            //\n            // Check that files exist\n            //\n\n            if (!File.Exists(parsedArgs.xmlFile))\n            {\n                throw new FileNotFoundException(\"XML file not found\", parsedArgs.xmlFile);\n            }\n\n            if (!File.Exists(parsedArgs.xsdFile))\n            {\n                throw new FileNotFoundException(\"Schema not found\", parsedArgs.xsdFile);\n            }\n\n            //\n            // Load the XML file and create the resource model from it\n            //\n\n            XmlDocument document = LoadDocument(parsedArgs.xmlFile, parsedArgs.xsdFile);\n            resourceModel = new ResourceModel(document, parsedArgs.outputDirectory);\n        }\n\n        public static void ReportArgumentError(string message)\n        {\n            Usage();\n            throw new ApplicationException(message);\n        }\n\n\n        //+-----------------------------------------------------------------------------","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/ResourceGenerator.cs#L173-L209","documentation":"ResourceGenerator.ProcessArgs throws FileNotFoundException when the XSD schema file supplied via parsedArgs.xsdFile does not exist. The XSD is required to validate the XML data file during loading, so the tool fails fast before LoadDocument runs.","triggerScenarios":"Running ResourceGenerator with an xsdFile path that does not exist: wrong schema name, schema not deployed alongside the tool, relative path broken by a different working directory.","commonSituations":"Copying the generator to a machine without the accompanying schema; build scripts that copy the XML but forget the XSD; renaming the schema during a tooling upgrade.","solutions":["Verify the XSD path exists at the exact location the tool resolves it.","Deploy/copy the schema next to the XML input and reference it explicitly with an absolute path.","Fix the schema argument in the invoking script or build target."],"exampleFix":"// before\ncsp ResourceGenerator model.xml oldschema.xsd\n// after\ncsp ResourceGenerator model.xml C:\\tools\\mcg\\schema.xsd","handlingStrategy":"validation","validationCode":"if (!File.Exists(xsdPath))\n    throw new FileNotFoundException($\"Schema file missing: {Path.GetFullPath(xsdPath)}\");","typeGuard":null,"tryCatchPattern":"try { generator.ProcessArgs(args); }\ncatch (FileNotFoundException ex) when (ex.FileName == xsdPath) { Console.Error.WriteLine($\"Schema not found: {ex.FileName}\"); return 2; }","preventionTips":["Deploy the XSD alongside the XML input and reference it by absolute path.","Add the schema to the build output/copy list so it ships with the tool.","Validate both input files exist in a pre-build step."],"tags":["filenotfound","schema","cli","codegen"],"backgroundTag":"file-not-found","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}