2013-01-23 54 views
1

我正在使用FWTools和SharpMap(使用gdal_sharp)構建應用程序。我有一個奇怪的錯誤。加載光柵層運行在調試模式很好,但在釋放它在構造函數中調用時,會產生異常情況SharpMap.Layers.GdalRasterLayer發佈版本中的FWTools/GDAL錯誤

_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} 

怪異的事情是在調試一切正常。構建設置是確切的,都是.Net 4.0,x86平臺。

任何想法?

三江源提前

+0

在Release配置中,所有C++項目中的運行時間是否相互匹配? – jglouie

+0

是的,他們確實匹配。檢查也。 –

回答

0

這似乎是與Windows 8的一個問題,它的DEP實現與.NET 4.0一起。我在包裝器中使用C++ dll,操作系統不讓它執行。可以通過編輯DLL或關閉Data Execution Prevention來解決該問題。