# Crash when select polygon by mouse cmIdentity

**URL:** <https://mapwindow.discourse.group/t/crash-when-select-polygon-by-mouse-cmidentity/406>\
**Category:** MapWinGIS\
**Created:** [December 30, 2019, 1:22am UTC](https://mapwindow.discourse.group/t/crash-when-select-polygon-by-mouse-cmidentity/406 "2019-12-30T01:22:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiennguyen](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tiennguyen](https://mapwindow.discourse.group/u/tiennguyen)\
**Post date:** [December 30, 2019, 1:22am UTC](https://mapwindow.discourse.group/t/crash-when-select-polygon-by-mouse-cmidentity/406/1 "2019-12-30T01:22:05Z")

</div>

Hi everyone. I’m Tien. I am writing a map in which I want to select polygon on the map. However, when I select polygon there was a error happening.

 ![image](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/65b1660bece1087f5f28dae5d72b3e0fb1c9b7bf.png)

Although I upgraded up to MapWinGis 5.1.1, this error still happened.  
Can you tell me how to do to solve it. Thanks a lot

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [December 30, 2019, 3:40am UTC](https://mapwindow.discourse.group/t/crash-when-select-polygon-by-mouse-cmidentity/406/2 "2019-12-30T03:40:17Z")

</div>

Hello @tiennguyen, and welcome.

I’m afraid you’ll have to provide more information.

1. I will assume that the MapWinGIS OCX is placed on the this form, `frmConsoleMenu`.
2. It would be most helpful if you could show the call stack to the error, and the Exception details, to see specifically who (what component) is raising the error, and where.

Thank you,  
Jerry.

---

<div class="post-metadata">

**Author:** ![tiennguyen](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tiennguyen](https://mapwindow.discourse.group/u/tiennguyen)\
**Post date:** [December 30, 2019, 4:21am UTC](https://mapwindow.discourse.group/t/crash-when-select-polygon-by-mouse-cmidentity/406/3 "2019-12-30T04:21:13Z")

</div>

Thank for your answer. Let me explain my problem.

- I use Mapwingis for frmMain form which is located in frmConsoleMenu form.

- when I create polygon, polyline on this map, it’s ok. However, I want to select polyline and polygon to edit or show its information . Polygon was createed like image following.

- There was a problem is that when I set cursorMode of axMap to cmIdentity by event:  
private void selectObject\_Click(object sender, EventArgs e)  
{  
if (axMap != null)  
{  
if (axMap.CursorMode != tkCursorMode.cmIdentify)  
axMap.CursorMode = tkCursorMode.cmIdentify;  
else  
axMap.CursorMode = tkCursorMode.cmNone;

I moved mouse on map and not yet click mouse, immediately crash occurred like image following.

 ![image](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/6d674f5fe735d375c6cb60f3d5580d0b3454a722.png)  
Note: frmMain form , which used mapwingis, is a child form of frmConsoleMenu.  
Here is a statement indicate it:  
static void Main()  
{  
Application.EnableVisualStyles();  
Application.SetCompatibleTextRenderingDefault(false);  
[//Application.Run](https://Application.Run)(new frmMain());  
clsCommon.gfrmRootMain = new frmConsoleMenu();  
Application.Run(clsCommon.gfrmRootMain);  
[//Application.Run](https://Application.Run)(new Form1());  
}  
private void frmConsoleMenu\_Load(object sender, EventArgs e)  
{  
if(frmMap == null)  
{  
frmMap = new frmMain(this);  
clsCommon.ShowFormOnPanel(this.panelView, frmMap);  
}  
}  
I did not understand what’s happen. Please help me repair it. Thanks a lot

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [December 30, 2019, 6:50am UTC](https://mapwindow.discourse.group/t/crash-when-select-polygon-by-mouse-cmidentity/406/4 "2019-12-30T06:50:46Z")

</div>

Thank you, but there’s still not enough information. I have more questions:

1. Regarding the `selectObject_Click` handler, what event are you handling? Perhaps `ShapeIdentified`? It’s not clear from the name.
2. Do you have HotTracking turned on for the Identifier? (`axMap.Identifier.HotTracking` property)
3. Since you’re only moving the mouse, and not clicking, it is not likely related to the event handler. Something else is going on.
4. It would be most helpful to have the Exception details, including the call stack, to see who is unhappy.

Respectfully,  
Jerry

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 3:08pm UTC](https://mapwindow.discourse.group/t/crash-when-select-polygon-by-mouse-cmidentity/406/5 "2022-01-05T15:08:56Z")

</div>


