0x00007FFCC30D3416 (ntdll.dll) (MyGIS.exe 中)处有未经处理的异常: 0xC0000005: 写入位置 0x0000000000000024 时发生访问冲突。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MapGIS.GeoMap;
using MapGIS.GISControl;
namespace MyGIS
{
public partial class Form1 : Form
{
MapControl mapCtrl = null;
//地图文档对象
Document doc = null;
//地图对象
Map map = null;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
mapCtrl = new MapControl();
this.mapCtrl.Dock = DockStyle.Fill;
this.panel1.Controls.Add(mapCtrl);
//打开指定地图文档
doc = new Document();
if (doc.Open(@"D:\MapGIS 10\Sample\地图文档.mapx") > 0)
{
//获取第一个地图
map = new Map();
map = doc.GetMaps().GetMap(0);
if (map != null)
{
//显示地图
this.mapCtrl.ActiveMap = map;
//复位窗口
this.mapCtrl.Restore();
}
else
{
MessageBox.Show("当前地图文档无地图数据");
return;
}
}
else
{
MessageBox.Show("打开失败!");
}
}
}
}
c#学习中,靴靴!!
问题应该在这条语句
if (doc.Open(@"D:\MapGIS 10\Sample\地图文档.mapx") > 0)
改为
if (doc.Open(@"D:\\MapGIS 10\\Sample\\地图文档.mapx") > 0)
试试,先测试一下doc是否为null值。