{"record":{"id":"de80e65fb4885b33","repo":"BornToBeRoot/NETworkManager","slug":"embedded-resource-networkmanager-resources-maps-world-cities","errorCode":null,"errorMessage":"Embedded resource \"NETworkManager.Resources.Maps.world-cities.json\" not found.","messagePattern":"Embedded resource \"NETworkManager\\.Resources\\.Maps\\.world-cities\\.json\" not found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"Source/NETworkManager/Controls/TracerouteMapControl.xaml.cs","lineNumber":1681,"sourceCode":"    /// Minimal representation of a simplified country outline (name + outer ring coordinates as [lon, lat] pairs).\n    /// </summary>\n    private sealed class CountryData\n    {\n        [JsonPropertyName(\"n\")]\n        public string N { get; set; }\n\n        [JsonPropertyName(\"r\")]\n        public List<List<List<double>>> R { get; set; }\n    }\n\n    private static List<CityData> LoadCities()\n    {\n        const string resourceName = \"NETworkManager.Resources.Maps.world-cities.json\";\n\n        var assembly = Assembly.GetExecutingAssembly();\n\n        using var stream = assembly.GetManifestResourceStream(resourceName) ??\n                            throw new FileNotFoundException($\"Embedded resource \\\"{resourceName}\\\" not found.\");\n        using var reader = new StreamReader(stream);\n\n        return System.Text.Json.JsonSerializer.Deserialize<List<CityData>>(reader.ReadToEnd()) ?? [];\n    }\n\n    /// <summary>\n    /// Minimal representation of a major city (national capital or population above the script's threshold).\n    /// </summary>\n    private sealed class CityData\n    {\n        [JsonPropertyName(\"n\")]\n        public string N { get; set; }\n\n        [JsonPropertyName(\"lat\")]\n        public double Lat { get; set; }\n\n        [JsonPropertyName(\"lon\")]\n        public double Lon { get; set; }","sourceCodeStart":1663,"sourceCodeEnd":1699,"githubUrl":"https://github.com/BornToBeRoot/NETworkManager/blob/2780d65469917a296dbc15f206107d72e2d0115c/Source/NETworkManager/Controls/TracerouteMapControl.xaml.cs#L1663-L1699","documentation":"TracerouteMapControl loads city coordinates from the embedded resource \"NETworkManager.Resources.Maps.world-cities.json\" via GetManifestResourceStream. When that resource is not present in the executing assembly, the null stream triggers a FileNotFoundException with this message, so the traceroute map cannot plot city locations.","triggerScenarios":"The resource loader is invoked (TracerouteMapControl construction) while the assembly lacks a manifest resource named exactly \"NETworkManager.Resources.Maps.world-cities.json\" — missing EmbeddedResource entry in the csproj, renamed/moved file, or a build that excluded the Resources/Maps folder.","commonSituations":"Custom or CI builds that did not embed the JSON; the file moved to another folder so the default-namespace-derived resource name changed; resource-stripping publish profiles; a locally modified repo missing the data file.","solutions":["Ensure the csproj embeds the file (<EmbeddedResource Include=\"Resources\\Maps\\world-cities.json\" />) and rebuild.","Check the exact resource name (default namespace + folder path) matches the constant; fix either the path or the resourceName.","Debug with assembly.GetManifestResourceNames() to see which names actually exist and align them.","Restore the missing world-cities.json from the repository and rebuild/redeploy the complete output."],"exampleFix":"// csproj before\n<None Remove=\"Resources\\Maps\\world-cities.json\" />\n// after\n<EmbeddedResource Include=\"Resources\\Maps\\world-cities.json\" />","handlingStrategy":"fallback","validationCode":"var names = Assembly.GetExecutingAssembly().GetManifestResourceNames();\nbool ok = names.Contains(\"NETworkManager.Resources.Maps.world-cities.json\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var cities = LoadCities();\n}\ncatch (FileNotFoundException ex)\n{\n    logger.Error(\"world-cities.json embedded resource missing\", ex);\n    MessageBox.Show(\"City data is missing from this installation. Please reinstall.\");\n}","preventionTips":["Ensure the csproj marks world-cities.json as EmbeddedResource.","Add a CI smoke test that enumerates manifest resources and checks both map JSON files.","Keep resource folder structure aligned with the default namespace so names stay stable.","Deploy full build outputs; verify resources after any packaging changes."],"tags":["csharp","embedded-resource","wpf","traceroute"],"backgroundTag":"resource-not-found","analyzedSha":"2780d65469917a296dbc15f206107d72e2d0115c","analyzedAt":"2026-09-12T17:00:17.986Z","contentChangedAt":"2026-09-12T17:00:17.986Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}