AE exception-code not accessed

Source: Internet
Author: User

Recently I learned about ArcEngine development and encountered a strange exception. The code is not accessible. After checking the code several times, the Code seems to me that there is no logic error, but there is no draw line. During the step-by-step operation, the process jumps out of the green code. Check again and again, add try {} catch {} in the green code, and finally throw an exception. Exception: "The object reference is not set to the instance of the object ". Check found that the check box for the exception settings is not selected (as shown below) (I do not know why it is not selected by default), VS does not automatically throw an exception, the process automatically jumps out when an unsolved problem occurs. After an exception is thrown, the error can be easily modified. Change the statement in the error field to ipolympus line pDrawPolyline = new ESRI. ArcGIS. Geometry. PolylineClass ();

Select all the check boxes that cause exceptions.

Bool DrawPolylineOrNot = false; // specifies whether to draw a line.

Int DrawPolylineClickCount; // specifies the number of points to be drawn when drawing a line.

Ipolympus line pDrawPolyline = null; // Error

 

Private void axmapcontrolpoliconmousedown (object sender, ESRI. ArcGIS. Controls. IMapControlEvents2_OnMouseDownEvent e)

{

If (e. button = 1)

{

IPoint pPoint = new PointClass ();

PPoint. PutCoords (e. mapX, e. mapY );

 

// Curve used to draw a Section

If (DrawPolylineOrNot)

{

// Click it for the first time and set the start point

If (DrawPolylineClickCount = 0)

{

PDrawPolyline. FromPoint = pPoint;

DrawPolylineClickCount ++;

}

Else if (DrawPolylineClickCount = 1)

{

PDrawPolyline. ToPoint = pPoint;

DrawPolylineClickCount = 0;

DrawPolylineOrNot = false;

AxMapControl1.DrawShape (pDrawPolyline );

AxMapControl1.Refresh ();

}

}

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.