this.globeControl.Host.RenderEngine is nullrenference

Sep 15, 2009 at 7:59 AM

code:

if (map != null) //map is SurfaceVEMap type
{
veGrid.Children.Remove(map);
GC.SuppressFinalize(map);

map = new SurfaceVEMap();
map.Width = 1024;
map.Height = 768;
map.MapStyle = VEMapStyle.Aerial;
map.HorizontalAlignment = HorizontalAlignment.Center;
map.VerticalAlignment = VerticalAlignment.Center;
map.MapLoaded += map_MapLoaded;
veGrid.Children.Add(map);
}

add the map to veGrid Control, an error happen :

VEMap.cs

void VEMap_Loaded(object sender, RoutedEventArgs e)
        {
            isControlLoaded = true;

            //Are we in Visual Studio Designer?
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                this.globeControl.Host.RenderEngine.Initialized += new EventHandler(RenderEngine_Initialized); //error message RenderEngine is null renference

                this.globeControl.InitRenderEngine();
            }
        }

Coordinator
Sep 16, 2009 at 5:16 AM

Please see this thread: http://virtualearthwpf.codeplex.com/Thread/View.aspx?ThreadId=54085

I don't have a better solution, but others have wrapped that line in a try { ... } catch {} (to ignore any exceptions it throws) and it seems to work.