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
0
Answers
Is the client run with administrator privileges?
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
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
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 try to run it as administrator?
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
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?
No I didn't.
If using the browser, you can debug it in the developer menu (For Google Chrome, the hotkey is f12)