0

我在窗口服务中使用 SharpMap。我正在使用该库生成地图,然后从中创建图像并将其添加到 Excel 文件中。该代码在 Quartz.net 任务中运行。

当我调用SharpMap.Map.GetMap()并破坏我的服务时会发生错误(请参阅下面的错误报告和堆栈调用)。

这种情况时不时发生(可能是数据问题?)。另请注意,我在使用地图时遇到了一些问题,所以我System.Threading.Thread.Sleep(5000);在调用函数之前放了一些延迟()。

我正在生成几个这样的图像,并且错误(上次发生)是在几次(~10)次迭代之后。为了不重新创建和格式化地图的“静态层” SharpMap.Map

有没有办法找到错误的原因?

有没有办法优雅地处理这种异常?

Windows CMS 错误报告 + 堆栈跟踪:

应用程序:NePTune.WinService.exe

框架版本:v4.0.30319

说明:进程因未处理的异常而终止。

异常信息:System.AccessViolationException

堆:

at System.Drawing.SafeNativeMethods+Gdip.GdipPathIterNextSubpathPath(System.Runtime.InteropServices.HandleRef, Int32 ByRef, System.Runtime.InteropServices.HandleRef, Boolean ByRef) 
at System.Drawing.SafeNativeMethods+Gdip.GdipPathIterNextSubpathPath(System.Runtime.InteropServices.HandleRef, Int32 ByRef, System.Runtime.InteropServices.HandleRef, Boolean ByRef) 
at System.Drawing.Drawing2D.GraphicsPathIterator.NextSubpath(System.Drawing.Drawing2D.GraphicsPath, Boolean ByRef) 
at SharpMap.Rendering.Symbolizer.WarpPathToPath.Warp(System.Drawing.Drawing2D.GraphicsPath, System.Drawing.Drawing2D.GraphicsPath, Boolean, Single) 
at SharpMap.Rendering.Symbolizer.WarpPathToPath.DrawString(System.Drawing.Graphics, System.Drawing.Pen, System.Drawing.Brush, System.String, System.Drawing.FontFamily, Int32, Single, System.Drawing.StringFormat, Boolean, System.Drawing.Drawing2D.GraphicsPath) 
at SharpMap.Layers.LabelLayer.Render(System.Drawing.Graphics, SharpMap.Map) 
at SharpMap.Map.RenderMap(System.Drawing.Graphics) 
at SharpMap.Map.GetMap() 
at NePTune.Logic.Algorithms.UlInterference.UlInterferenceReportWriter.CreateClusterMap(System.Collections.Generic.List1<NePTune.Data.SectorGeoDetails>, System.Collections.Generic.Dictionary2<Int32,Double>, Int32, System.Collections.Generic.IEnumerable1<NePTune.Data.SectorGeoDetails>, Boolean) 
at NePTune.Logic.Algorithms.UlInterference.UlInterferenceReportWriter.CreateInterferenceClusterWorksheets(OfficeOpenXml.ExcelPackage, System.Collections.Generic.List1<NePTune.Logic.Algorithms.UlInterference.UlInterferenceCluster>, System.Collections.Generic.Dictionary2<Int32,NePTune.Data.SectorGeoDetails>, System.Collections.Generic.Dictionary2<Int32,NePTune.Logic.Algorithms.UlInterference.CellMeasurementList>) 
at NePTune.Logic.Algorithms.UlInterference.UlInterferenceReportWriter.CreateReport(System.Collections.Generic.List1<NePTune.Logic.Algorithms.UlInterference.CellUlInterferenceResults>, System.Collections.Generic.List1<NePTune.Logic.Algorithms.UlInterference.UlInterferenceCluster>, System.Collections.Generic.Dictionary2<Int32,NePTune.Data.SectorGeoDetails>, System.Collections.Generic.Dictionary2<Int32,NePTune.Logic.Algorithms.UlInterference.CellMeasurementList>) 
at NePTune.Logic.Algorithms.UlInterference.UlInterferenceDriver.Execute(NePTune.Common.Configuration.GlobalConfiguration, NePTune.Logic.Algorithms.UlInterference.UlInterferenceConfiguration) 
at NePTune.Logic.Algorithms.AlgorithmJobs.UlInterferenceJob.Execute(NePTune.Common.Configuration.GlobalConfiguration, NePTune.Logic.Algorithms.Common.IAlgorithmConfiguration, System.String, System.String, System.String) 
at NePTune.Logic.Algorithms.AlgorithmJobs.UlInterferenceJob.Execute(Quartz.IJobExecutionContext) 
at Quartz.Core.JobRunShell.Run() 
at Quartz.Simpl.SimpleThreadPool+WorkerThread.Run() 
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
at System.Threading.ThreadHelper.ThreadStart()
4

1 回答 1

0

我在 CodePlex ( https://sharpmap.codeplex.com/ )上的 SharpMap 项目页面中讨论了这个问题,他们建议在调用获取地图之前克隆地图。

在添加我的“动态图层”然后调用GetMap().

这可以防止访问冲突。

在此处查看更多详细信息: https ://sharpmap.codeplex.com/discussions/558218

于 2014-08-31T07:28:01.040 回答