NAV crashes when closing page with add-in

ACaignieACaignie Member Posts: 82
Hello,
I have created a javascript add-in that uses leaflet to display map information. This works fine, however from time to time NAV crashes when the page with the add-in is closed. I think there is a problem with an event that is triggered after the page is closed, however I cannot find what it can be.
Does anyone know a way to find the issue?
We are using NAV2017 CU23 (RTC, not web client)
This is (part of) the error that is logged in the event viewer:

Application: Microsoft.Dynamics.Nav.Client.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at System.Windows.Forms.UnsafeNativeMethods+IOleInPlaceActiveObject.TranslateAccelerator(MSG ByRef)
at System.Windows.Forms.WebBrowserBase.PreProcessMessage(System.Windows.Forms.Message ByRef)
at Microsoft.Dynamics.Framework.UI.WinForms.WebBrowserForNavigation.PreProcessMessage(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(System.Windows.Forms.Control, System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Application+ThreadContext.PreTranslateMessage(MSG ByRef)
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window)
at Microsoft.Dynamics.Framework.UI.WinForms.Controls.BusinessForm.ShowDialog(System.Windows.Forms.Form, System.Windows.Forms.IWin32Window)
at Microsoft.Dynamics.Framework.UI.WinForms.FormPanel.DoModal(Microsoft.Dynamics.Framework.UI.LogicalForm)
at Microsoft.Dynamics.Framework.UI.Windows.LogicalFormAdapterBase.DoModal(Microsoft.Dynamics.Framework.UI.LogicalForm)
at Microsoft.Dynamics.Framework.UI.Windows.ClientSessionBase.OnFormToShow(Microsoft.Dynamics.Framework.UI.LogicalForm, Microsoft.Dynamics.Framework.UI.LogicalControl)
at Microsoft.Dynamics.Framework.UI.WinForms.ClientSession.OnFormToShow(Microsoft.Dynamics.Framework.UI.LogicalForm, Microsoft.Dynamics.Framework.UI.LogicalControl)
at Microsoft.Dynamics.Framework.UI.UISession.ShowDialog(Microsoft.Dynamics.Framework.UI.LogicalForm, Microsoft.Dynamics.Framework.UI.LogicalForm)

Exception Info: System.Reflection.TargetInvocationException
at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
at System.Delegate.DynamicInvokeImpl(System.Object[])
at Microsoft.Dynamics.Framework.UI.WinForms.ExceptionWrapper.RunTryCatch(System.Object, System.Delegate, System.Object[])



Thx in advance,
Andy

Answers

  • PhoguePhogue Member Posts: 43
    edited 2020-01-14
    Does your event viewer give any more information than this?

    Is the client run with administrator privileges?
  • RockWithNAVRockWithNAV Member Posts: 946
    System is saying some unhandled exception for this so you need to debug this and figure out, remove your addin and see if its working and if its working then verify your addin as there's something wrong as from NAV'S Protocol OR If something from NAV you have to do to handle that.
  • ACaignieACaignie Member Posts: 82
    Phogue wrote: »
    Does your event viewer give any more information than this?

    Is the client run with administrator privileges?
    I attached the full event viewer message as images (too long to post, and can't seem to add a txt file). The client is run with normal priviliges

  • ACaignieACaignie Member Posts: 82
    System is saying some unhandled exception for this so you need to debug this and figure out, remove your addin and see if its working and if its working then verify your addin as there's something wrong as from NAV'S Protocol OR If something from NAV you have to do to handle that.

    The only object on the page is the add-in, and some actions. Removing the addin makes the page useless, but of course it works then. I would like to debug the addin, but this is a javascript addin running in the RTC. I haven't found a way yet to do this. I can debug it using the web client, but this is a different program
  • PhoguePhogue Member Posts: 43
    System is saying some unhandled exception for this so you need to debug this and figure out, remove your addin and see if its working and if its working then verify your addin as there's something wrong as from NAV'S Protocol OR If something from NAV you have to do to handle that.

    more precisely System.AccessViolationException

    Which could be several things, like trying to perform an operation administrative privileges, or access something you don't have permission to.

    RockWithNAV is right - always try to use the debugger to find the culprit.
  • PhoguePhogue Member Posts: 43
    I attached the full event viewer message as images (too long to post, and can't seem to add a txt file). The client is run with normal priviliges

    can you try to run it as administrator?
  • ACaignieACaignie Member Posts: 82
    Phogue wrote: »
    I attached the full event viewer message as images (too long to post, and can't seem to add a txt file). The client is run with normal priviliges

    can you try to run it as administrator?
    I did run it as administrator, and then it did not crash. But the crash only happens from time to time and is hard to reproduce
  • ACaignieACaignie Member Posts: 82
    Phogue wrote: »
    System is saying some unhandled exception for this so you need to debug this and figure out, remove your addin and see if its working and if its working then verify your addin as there's something wrong as from NAV'S Protocol OR If something from NAV you have to do to handle that.

    more precisely System.AccessViolationException

    Which could be several things, like trying to perform an operation administrative privileges, or access something you don't have permission to.

    RockWithNAV is right - always try to use the debugger to find the culprit.

    Can you explain how I can debug this? It's not a NAV error, and I don't know how to debug a javascript addin using the RTC
  • PhoguePhogue Member Posts: 43
    edited 2020-01-15
    If you wish to debug control-addins, I'm fairly sure you could use Visual Studio and select "Attach to Process" under the Debug pane, and select "Microsoft.Dynamics.Nav.Client.exe"

    You said you wrote the add-in yourself; does it do anything specific when closed?
    I'm somewhat confident, that the issue was due to lack of privileges (why it wouldnt crash with administrative privileges)
  • ACaignieACaignie Member Posts: 82
    Phogue wrote: »
    If you wish to debug control-addins, I'm fairly sure you could use Visual Studio and select "Attach to Process" under the Debug pane, and select "Microsoft.Dynamics.Nav.Client.exe"

    You said you wrote the add-in yourself; does it do anything specific when closed?
    I'm somewhat confident, that the issue was due to lack of privileges (why it wouldnt crash with administrative privileges)

    I tried to attach in VS, and the debugger is triggered by the error in NAV. But I can't see how to attach the debugger to the code in JS, as you can do with a C# addin.
    Thee addin doesn't do anything when it is closed.
    I tried to add this code to the add-in:

    window.onerror = function (errMsg, url, line, column, error) {
    var suppressErrorAlert = true;
    return suppressErrorAlert;
    };
    but this doesn't prevent the crash. Does anyone know if I could suppress it in another way?
Sign In or Register to comment.