{"record":{"id":"205767ec664b0adf","repo":"lionsoul2014/ip2region","slug":"xdb-file-not-found","errorCode":null,"errorMessage":"xdb file not found.","messagePattern":"xdb file not found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"binding/csharp/IP2Region.Net/XDB/Util.cs","lineNumber":45,"sourceCode":"    {\n        byte[] bytes = ipAddress.GetAddressBytes();\n        Array.Reverse(bytes);\n        return MemoryMarshal.Read<uint>(bytes);\n    }\n\n    public static uint GetMidIp(uint x, uint y)\n        => (x & y) + ((x ^ y) >> 1);\n\n    public static async Task<XdbVersion> GetVersionAsync(string dbPath, CancellationToken token = default)\n    {\n        if (string.IsNullOrEmpty(dbPath))\n        {\n            throw new ArgumentNullException(nameof(dbPath));\n        }\n\n        if (!File.Exists(dbPath))\n        {\n            throw new FileNotFoundException(\"xdb file not found.\", dbPath);\n        }\n\n        using var reader = File.OpenRead(dbPath);\n        return await GetVersionAsync(reader, token);\n    }\n\n    internal static async Task<XdbVersion> GetVersionAsync(FileStream reader, CancellationToken token = default)\n    {\n        XdbVersion ret = default;\n        var buffer = ArrayPool<byte>.Shared.Rent(256);\n\n        try\n        {\n            var length = await reader.ReadAsync(buffer, 0, 256, token);\n            if (length == 256)\n            {\n                ret = Parse(buffer);\n            }","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/csharp/IP2Region.Net/XDB/Util.cs#L27-L63","documentation":".NET FileNotFoundException from GetVersionAsync's File.Exists pre-check: the dbPath was supplied but no file exists at that location (wrong path, not-yet-created database, or working-directory mismatch in relative paths).","triggerScenarios":"Thrown at binding/csharp/IP2Region.Net/XDB/Util.cs:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the path is correct and the xdb file actually exists (use an absolute path to avoid cwd issues)","Ensure the file is deployed/copied to the output directory or container image","Create or download the xdb database before first use"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}