{"record":{"id":"96b76249fa9b3ba3","repo":"BornToBeRoot/NETworkManager","slug":"embedded-resource-networkmanager-resources-maps-world-map","errorCode":null,"errorMessage":"Embedded resource \"NETworkManager.Resources.Maps.world-map.json\" not found.","messagePattern":"Embedded resource \"NETworkManager\\.Resources\\.Maps\\.world-map\\.json\" not found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"Source/NETworkManager/Controls/TracerouteMapControl.xaml.cs","lineNumber":1656,"sourceCode":"                bestBoundsArea = boundsArea;\n                bestCenter = new Point((minX + maxX) / 2, (minY + maxY) / 2);\n            }\n\n            if (bestBoundsArea >= 0)\n                labels.Add((country.N, bestCenter));\n        }\n\n        return labels;\n    }\n\n    private static List<CountryData> LoadCountries()\n    {\n        const string resourceName = \"NETworkManager.Resources.Maps.world-map.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<CountryData>>(reader.ReadToEnd()) ?? [];\n    }\n\n    /// <summary>\n    /// 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()","sourceCodeStart":1638,"sourceCodeEnd":1674,"githubUrl":"https://github.com/BornToBeRoot/NETworkManager/blob/2780d65469917a296dbc15f206107d72e2d0115c/Source/NETworkManager/Controls/TracerouteMapControl.xaml.cs#L1638-L1674","documentation":"TracerouteMapControl loads the world-map GeoJSON from an embedded resource named \"NETworkManager.Resources.Maps.world-map.json\" via Assembly.GetManifestResourceStream. If the resource is absent from the executing assembly (build misconfiguration, wrong resource name, or stripped resources), the null stream is converted into a FileNotFoundException with this message.","triggerScenarios":"Calling the private resource loader in TracerouteMapControl (constructor path) when the assembly has no manifest resource with the exact name \"NETworkManager.Resources.Maps.world-map.json\" — e.g. the .csproj lacks the EmbeddedResource entry, the file lives under a different folder namespace, or a custom/partial build omitted it.","commonSituations":"Hand-compiled or modified builds where world-map.json was not included as EmbeddedResource; resource file moved/renamed in the repo without updating the csproj; custom packaging tools stripping resources; running a trimmed/published output that dropped the resource.","solutions":["Verify Source/NETworkManager.csproj contains <EmbeddedResource Include=\"Resources\\Maps\\world-map.json\" /> (or equivalent glob) and rebuild the NETworkManager project.","Confirm the resource name matches the default namespace + folder path (NETworkManager.Resources.Maps.world-map.json); rename the file/folder or the resourceName constant accordingly.","List actual resources at runtime with assembly.GetManifestResourceNames() to compare names and fix the mismatch.","Restore the original world-map.json if it was deleted, then rebuild and redeploy the full build output."],"exampleFix":"// csproj before\n<None Include=\"Resources\\Maps\\world-map.json\" />\n// after\n<EmbeddedResource Include=\"Resources\\Maps\\world-map.json\" />","handlingStrategy":"fallback","validationCode":"var names = Assembly.GetExecutingAssembly().GetManifestResourceNames();\nbool ok = names.Contains(\"NETworkManager.Resources.Maps.world-map.json\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var countries = LoadCountries();\n}\ncatch (FileNotFoundException ex)\n{\n    logger.Error(\"world-map.json embedded resource missing\", ex);\n    MessageBox.Show(\"Map data is missing from this installation. Please reinstall.\");\n}","preventionTips":["Keep world-map.json as an EmbeddedResource in the csproj; never switch it to None/Content accidentally.","Add a unit test asserting GetManifestResourceStream(\"NETworkManager.Resources.Maps.world-map.json\") != null.","When moving resource files, update both the folder path and the resourceName constant together.","Avoid resource-stripping publish settings that drop embedded assets."],"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"}