我正在使用 FWTools 和 SharpMap(带有 gdal_sharp)来构建应用程序。我有一个奇怪的错误。加载栅格图层在调试模式下运行良好,但在发布时调用时在构造函数中的 SharpMap.Layers.GdalRasterLayer 中引发异常
_projectionWkt = _gdalDataset.GetProjectionRef();
完整的例外是:
{System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at OSGeo.GDAL.GdalPINVOKE.Dataset_GetProjectionRef(HandleRef jarg1)
at OSGeo.GDAL.Dataset.GetProjectionRef()
at SharpMap.Layers.GdalRasterLayer..ctor(String strLayerName, String imageFilename) in d:\Fakultet\IX Semestar\GIS\Projekat\GreenGIS\SharpMap.Extensions\Layers\GdalRasterLayer.cs:line 404
at GreenGIS.Form1.addRasterLayer() in d:\Fakultet\IX Semestar\GIS\Projekat\GreenGIS\GreenGIS\Form1.cs:line 50
at GreenGIS.Form1.toolStripButtonAddVector_Click(Object sender, EventArgs e) in d:\Fakultet\IX Semestar\GIS\Projekat\GreenGIS\GreenGIS\Form1.cs:line 129
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.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.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(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 GreenGIS.Program.Main() in d:\Fakultet\IX Semestar\GIS\Projekat\GreenGIS\GreenGIS\Program.cs:line 19}
奇怪的是,在 Debug 中一切正常。构建设置是准确的,包括 .Net 4.0、x86 平台。
有任何想法吗?
先感谢您