Create Map Cache manual

Discussion created by KevinGebhardt86 on Mar 12, 2013
I'm trying to generate Map Caches from MapServices.
The reason is, i need to generate caches for given extents automatically.
Here is my approach with ArcObjects for .NET:

IMapDocument mapDocument = new MapDocument();
                            IMap map = mapDocument.get_Map(0);
                            IMapCooker mapCooker = new MapCooker();

                            // Giving the MapCooker the Extent of a Feature
                            mapCooker.Extent = feature.Extent;
                            ILayer layer = map.get_Layer(0);
                            // ILayer and Map are not NULL
                            // Where do I get my IDisplay-Object from?
                            ESRI.ArcGIS.Display.IDisplay display = new ESRI.ArcGIS.ArcMapUI.AppDisplay();
                            // Need I to add the Layer to the MapCooker?
                            mapCooker.AddLayer(layer.Name, layer);
                            if (map != null && layer != null)
                                    mapCooker.Generate(map, layer, display, cancel);
                                Logger.Log("w", "Map und/oder Layer sind NULL. Cache konnte nicht erstellt werden.");
After calling mapCooker.Generate() i get the following error:
Exception HRESULT: 0x000000A. The data necessary to complete this operation is not yet available.

Has anyone an idea?

Thanks in advance.