Brother labelprinter automation problem (Navision crash)

Tom_TaffinTom_Taffin Member Posts: 4
Hi everybody,

Did someone ever tried to link Navision to a Brother QL-580N labelprinter by using the P-Touch / b-PAC SDK automation (also delivered by Brother) ?
Labels are configured in the P-Touch software and the templates are then used for printing data from Navision.

This could be the code:

CREATE(autLabelDocG);
autLabelDocG.Open('c:\item.lbx'); //This is the template created in P-Touch

intIndexG := autLabelDocG.GetTextIndex('Barcode'); //'Barcode' is a text label in the template
autLabelDocG.SetText(intIndexG,'*'+item."No."+'*'); //'Barcode'-text is now replaced by the item number

autLabelDocG.StartPrint('test',0);
autLabelDocG.PrintOut(1,0);
autLabelDocG.EndPrint;
autLabelDocG.Close;
CLEAR(autLabelDocG);

This works fine if I look at the result coming out of the printer, but Navision crashes every time the code runs.
An "internal error"-message appears (without module-no.).

Strange thing is that the error only occurs when the complete code is executed. So I can debug my complete object (with multiple printouts if needed) and during the last step in my debugger the internal error occurs.
The tests were done on Navision 3.70 and NAV2009.

Does anybody have experience with this ?

Thank you very much in advance for your replies.

Tom

Comments

  • ara3nara3n Member Posts: 9,256
    could you comment out the clear(automation) and see if it still crashes?


    turn on the debugger and see at what line it crashes.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Tom_TaffinTom_Taffin Member Posts: 4
    Thank you for the reply!

    Deleting the CLEAR or close-lines does not solve the problem.
    It actually crashes on the last line of the code. So if I add some code now, it will execute everything and crash on the moment that the object is closed.
    I tried to simulate 3 print-commands in 1 piece of code. The printer printed 3 labels and navision crashed afterwards.
  • KYDutchieKYDutchie Member Posts: 345
    Tom,

    I have experienced a similar thing. It was with the Excel automation. I was able to fix it with the second parameter in the CREATE statement.

    Can you try and create your automation with the second parameter of TRUE.

    CREATE(autLabelDocG,TRUE);

    This will always create a new instance for your automation.

    let us know if that worked.

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • ara3nara3n Member Posts: 9,256
    can you make the CU single instance?
    I'm guessing the print job hasn't finished before you are clearing the variable.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rdebathrdebath Member Posts: 383
    Actually, this sounds like what was happening to the client when I was playing around with making codeunits persistent without making them single instance (successfully that is).

    Tom, are you doing anything 'unusual' with the codeunit, the main thing I'm thinking of is passing a copy of a codeunit around and into the codeunit itself. If the last reference to the codeunit goes out of scope while it's being executed the client will crash.

    If not then I suppose it's your average corruption problem; if single instancing a link codeunit doesn't work you might try creating an out of process wrapper DLL/EXE. It's slower but at least it cannot crash Navision. Another possibility is to use the VBScript DLL to call your printer DLL, VBScript uses different calling methods that are sometimes more robust against bad DLLs.
  • Tom_TaffinTom_Taffin Member Posts: 4
    Hi Guys,

    Thank you very much for your answers. Unfortunately it seems to be impossible to solve the issue directly in Navision.
    I created a VBScript to call the printer automation and from Navision I just call the VBScript with a SHELL command.

    It's working...but not the most ideal solution :-).
Sign In or Register to comment.