|     Documentation    |     Premium Support

InMemoryRasterTileCache.GetTile crashes when tile not found

InMemoryRasterTileCache.GetTile throws KeyNotFoundException when the tile is not in the cache:

        TileCache cache1 = new FileRasterTileCache();
        TileCache cache2 = new EncryptedFileRasterTileCache();
        TileCache cache3 = new InMemoryRasterTileCache();
        cache1.GetTile(123, 456, 789); // returns a tile with Bitmap==null
        cache2.GetTile(123, 456, 789); // returns null
        cache3.GetTile(123, 456, 789); // crashes

I do not know what the correct return value for that case should be, but classes like WmtsLayer do not expect an exception, and do not draw any tiles.

Hey @Clemens_Ladisch,

Thanks for bringing this up. We added a check to see if it exists in the cache, otherwise it will return null instead of throwing an exception. It will be available in the beta package later today if you want to check it out on your side.