In Desktop 4.5.0.0 the following code works. In 4.5.137.0 the last line returns a 'System.NullReferenceException was unhandled' error (see below). Why? What do I do to fix?
private void LoadRaster()
{
GdiPlusRasterLayer RasterLayer = new GdiPlusRasterLayer("Sedgwick_1ST_FLOOR_Site.png", "Sedgwick_1ST_FLOOR_Site.pgw");//, tempFile);// (@"East179-white.png");// (@"algoa.jpg");//, @"59and8.jgw");// (@"algoa.jpg", imageExtents);
RasterLayer.UpperThreshold = double.MaxValue;
RasterLayer.LowerThreshold = 0;
RasterLayer.Transparency = 255;
RasterLayer.Open();
RectangleShape rect = RasterLayer.GetBoundingBox();
RasterLayer.Close();
LayerOverlay ImageOverlay1 = new LayerOverlay();
ImageOverlay1.Layers.Add("RasterLayer", RasterLayer);
Map.Overlays.Add(ImageOverlay1);
Map.CurrentExtent = DoubleSize(rect);
double LargestScale = Map.CurrentScale;
RecalculateZoomLevels(LargestScale, .30);
Map.ZoomToScale(Map.ZoomLevelSet.ZoomLevel03.Scale);
Map.Refresh();
}
Thank you,
Dave
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=MapSuiteCore
StackTrace:
at ThinkGeo.MapSuite.Core.GdiPlusRasterSource.GetImageCore(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)
at ThinkGeo.MapSuite.Core.RasterSource.GetImage(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)
at ThinkGeo.MapSuite.Core.RasterLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.GdiPlusRasterLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.Overlay.tRM=(GeoCanvas thM=)
at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.4RU=(IEnumerable`1 4hU=)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.3xU=(RectangleShape 4BU=)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.LhY=()
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.KhY=(Int32 KxY=)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.Refresh()
at MapMemTest.MapTab.LoadRaster() in C:\Users\Dave\Documents\Visual Studio 2010\Scratch\MapMemTest\MapMemTest\MapTab.cs:line 56
at MapMemTest.MapTab..ctor() in C:\Users\Dave\Documents\Visual Studio 2010\Scratch\MapMemTest\MapMemTest\MapTab.cs:line 23
at MapMemTest.Form1.makeATabToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Users\Dave\Documents\Visual Studio 2010\Scratch\MapMemTest\MapMemTest\Form1.cs:line 21
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.MenuStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at MapMemTest.Program.Main() in C:\Users\Dave\Documents\Visual Studio 2010\Scratch\MapMemTest\MapMemTest\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: