Welcome to APLNext Sign in | Join | Help
in
Community Website
Blogs Forums

Tracking down errors - development practices

Last post 10-25-2007, 12:35 PM by Chris.McIntosh. 3 replies.
Sort Posts: Previous
  • Tracking down errors - development practices

     10-23-2007, 5:58 PM

    I'm developing a small project in VisualAPL.  I'm developing it as a project, rather than using scripts.  The problem I'm having is tracking down errors.

    So far I'm getting a lot of File=AplNext.targets, Line=14, Column=5 errors.  This is of no help in trying to figure out where my errors are.  As I'm just getting started, I'm making a lot of errors which isn't helping.

    Is there a way I can get error messages telling me what line and column of my source code errors are on?  Am I developing the wrong way?  I thought of developing in the Cielo editor using scripts, and then cutting and pasting to project files, but that seems to have some problems too.  Some of the things I'd use in project files, like Namespaces, properties of classes (I think?) and other things seem to work a bit differently in scripts than in classes, and I don't want to be converting back and forth.

    Any suggestions you can give me would be appreciated.

    Chris.

    P.S.  I'm not sure it makes any difference, but the VisualAPL project type I'm working on is a Class Library.

  • Re: Tracking down errors - development practices

     10-24-2007, 5:06 AM

    Chris, I append some code below:

    try
      {
       throw new Exception ("Runtime error-handling simulation.");
      }
    catch (Exception MyEx)
      {
       string dm = "Unexpected error in " + MyEx.TargetSite.Module.Name.ToUpper()  + " with " + MyEx.TargetSite.Name;
       System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(MyEx, true);
       dm += " at line " + trace.GetFrame(0).GetFileLineNumber() + " column " + trace.GetFrame(0).GetFileColumnNumber();
       dm += ".\r\n" + MyEx.Message;
       MessageBox.Show(dm,"C# Diagnostic Message");
      }

     

    Notes:

     

    1. Your code should go within the try block;  in the sample above, I am generating an error arbitrarily.

    2. I am using MessageBox.Show; since you are developing a class library, you will need to add a reference to System.Windows.Forms to your project ( ... perhaps just during the debugging phase?) or circumvent this by writing the message, dm, to a public property in your class such that it can be queried by the client you are using to test the class.

     

    Another approach:

     

    a. In Project Properties| Debug | select "Start External Program" and specify your client application.

     

    b. On any (suspect line) press F9.

     

    c. Run the Server (i.e. your class library); it will launch the client from which you can trigger the code in the server to run and it will stop on all F9 lines in the server code.

     

    d. Then Press F11 to step through the code: this may isolate the location/nature and source of the error.

     

     

  • Re: Tracking down errors - development practices

     10-24-2007, 5:13 AM

    Attachment: errmsg.zip
    The attached zip file contains a BMP that shows the error message generated by the code in my client session.
  • Re: Tracking down errors - development practices

     10-25-2007, 12:35 PM

    Ajay, this is quite ingenious, and I think I'll be using it a lot in future.  Thank you.  However, it doesn't help me right now, as the message I'm getting is a compile time, rather than a run time error.  Chris.

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems