Thank you all for your feedback.
Some more information. This problem only occurs with my user. Other users are able to use 'Incoming Document' and upload new purchase invoices. Furthermore they can also open the purchase invoices I made. For me both opening purchase invoices and purchase orders will crash NAV. If I open a blanked purchase order, NAV doesn't crash.
When the crash occurs we see 5 error messages in the event viewer. The first message is:
Server instance: DynamicsNAV
Tenant ID: <ii>default</ii>
<ii>Session type: RoleTailoredClient
Session ID: 58374
User: Gert-Jan
Type: System.InvalidOperationException
Message: <ii>An internal error has occurred. Cannot assign a scope id. The maximum number of methods for 5 1854 has been exceeded.</ii>
StackTrace: at Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args)
Source: Microsoft.Dynamics.Nav.Ncl
HResult: -2146233079
----------------------------------
Type: System.Reflection.TargetInvocationException
Message: <ii>Exception has been thrown by the target of an invocation.</ii>
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args)
Source: mscorlib
HResult: -2146232828
----------------------------------
Type: System.InvalidOperationException
Message: <ii>An internal error has occurred. Cannot assign a scope id. The maximum number of methods for 5 1854 has been exceeded.</ii>
StackTrace:
at Microsoft.Dynamics.Nav.Runtime.ALCodeEnvironment.GetOrAssignScopeId(ApplicationObjectId objectId, IRawScopeIdProvider scopeIdProvider, Boolean setBreakpointFlag)
at Microsoft.Dynamics.Nav.Runtime.CallStackElement..ctor(NavMethodScope scope)
at Microsoft.Dynamics.Nav.Runtime.NavSession.BuildCurrentStack()
at Microsoft.Dynamics.Nav.Runtime.NavSession.set_LastException(Exception value)
at Microsoft.Dynamics.Nav.Runtime.NavMethodScope.ProcessException(Exception exception)
at Filter.InvokeWithFilter(NavMethodScope )
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dynamics.Nav.EventSubscription.NavEventScope.CallEventSubscriber(NavEventSubscription subscriber, NavApplicationObjectBase subscriberInstance, Object[] parameters)
at Microsoft.Dynamics.Nav.EventSubscription.NavEventScope.ProcessCallToTypeAndManualSubscriptions(NavApplicationObjectBase callerApplicationObject, NavEventSubscription[] subscriptions, PrepareParametersCallBack prepareParameters)
at Microsoft.Dynamics.Nav.EventSubscription.NavEventScope.ProcessCallToAllSubscribers(NavApplicationObjectBase callerApplicationObject, PrepareParametersCallBack prepareParameters)
at Microsoft.Dynamics.Nav.EventSubscription.NavPageTriggerEventHandler.OnAfterGetCurrRecordEvent(NavForm page, INavRecordHandle rec)
at Microsoft.Dynamics.Nav.Runtime.NavForm.RaiseTriggerEvent(NavTriggerEventType eventType, Action action)
at Microsoft.Dynamics.Nav.Runtime.NavForm.RaiseOnAfterGetCurrRecord()
at Microsoft.Dynamics.Nav.Runtime.NavForm.AfterGetCurrRecord()
Source: Microsoft.Dynamics.Nav.Ncl
HResult: -2146233079