Is it possible to get the error line (as Erl)?

Discussion in 'Questions (Windows Mobile)' started by RB Smissaert, Dec 29, 2008.

  1. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Is it possible (without adding extra lines of code) to get the line in the code where a runtime error happened? I am thinking of something like Erl as in VBA and VB6. I am getting an intermittent NullReferenceException that I can't explain and gettting the error line would help to track this down.

    RBS
     
  2. agraham

    agraham Expert Licensed User

    Are you running on the desktop or device, in the IDE, legacy or optimised compiled? We really need a bit more information than "I am getting ..." :(

    Assuming an optimised compiled app on the device - the IDE should give the error line number - you won't be able to do anything to find it without adding extra code, why is this a problem? Assuming you are running under .NET 2.0 or later you can trap the error with my Exceptions2 library http://www.basic4ppc.com/forum/additional-libraries/2305-exceptions-handling-library.html and look at the stack trace that may give you an indication. If the error is ocurring in a large Sub then you could see if you can split it into several smaller Subs to isolate the section of code where the problem is ocurring.
     
  3. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    > We really need a bit more information than "I am getting ..."

    i AM NOT ASKING FOR HELP WITH CODE DEBUGGING, BUT JUST WOULD LIKE TO KNOW IF THERE WAS A SIMPLE WAY TO GET THE ERROR LINE.
    iT LOOKS THEN THIS CAN'T BE DONE WITHOUT ADDING EXTRA LINES OF CODE, BASICALLY CODING: i HAVE BEEN HERE AND NO ERROR YET, ETC.
    wILL HAVE A LOOK AT YOUR ERROR LIBRARY AND THANKS FOR MAKING THAT
    AVAILABLE.

    rbs

    PS: IF THIS COMES OUT WRONG, MY KEYBOARD IS SHOWING THE CASING OPPOSITE.
     
  4. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Ah, yes, that is of course the answer. I can run it on the device from the IDE!
    I don't get this error on the desktop, so if running it from the device IDE is the same as running the compiled .exe on the device (is it?) then that should tell me the error line.
    Thanks for that tip.
    Will report back once I have this tracked down as intermittent errors are always somewhat worrying.

    RBS
     
  5. agraham

    agraham Expert Licensed User

    I am afraid that it is not. Which is why the information upon the platform and environment is useful to know. Legacy compiled apps and the IDE are interpreted environments, optimised compiled apps are translated into C# then fully compiled by the .NET Framework C# compiler into "proper" exes. Full compilation gives a large performance increase at the expense of occasional incompatibilities - which are (mainly but not always) confined to the interface to external libraries. As time goes by these incompatibilities are being eliminated as they are found so only fairly arcane ones now (probably!) exist.

    As the device IDE is interpreted it may behave differently (say under race conditions) than a fully compiled app so you may need to try and get a stack trace from the compiled app if the failure doesn't ocurr in the IDE.
     
    Last edited: Dec 30, 2008
  6. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    This is all bang standard, newly developed app with latest version of Basic4ppc, WM6, optimized compiled (force VGA or something like that, haven't got the IDE with me now) run it on a Samsung Omnia.
    Let's hope running it from the device IDE will show me the error line then.
    It is a pity there is no such thing as Erl as in VB6/VBA.

    RBS
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    After compiling a program it is not possible to match the compiled .Net intermediate code (which is the compilation result) and the original Basic4ppc code.
    I'm thinking of creating a special compiling mode which will add some profiling information, and it could also add code which will show error lines.
    This could be useful during development.
     
  8. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Thanks Erel, that would be very useful.

    RBS
     
  9. agraham

    agraham Expert Licensed User

    I hava little utility (written in Basic4ppc :)) that adds a line number to the error message shown in an optimised compiled app when it hits an unhandled exception.

    It's a bit arcane to use as it patches the C# code file produced by the optimising compiler then recompiles it and the error line number it shows is not the true line number of the sbp file. However from the line number you can find the C# source line and from that identify the Basic4ppc line. I've used it on the desktop but there's no reason why it wouldn't work on the device.

    It's not at all polished and I don't want to post it in the forum but if you need it and are happy to look at C# code then PM an email address to me and I'll send it to you.
     
  10. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Thanks for the offer and I will bear it in mind. I think I have fixed this bug now and I think it had to do with comparing strongly typed variables (in a globally declared array) with local variant variables. I changed these global variables to variants and haven't seen the problem since, so maybe that was it.
    I am not familiar with C#, but I will let you know if I have a need for your utility.

    RBS
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice