Hi all,
One of my event subscribers in NAV2016 is causing an unhandled exception.
As soon as the event is fired, I'm getting this exception in the client:
The NST event viewer:
Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace:
at Microsoft.Dynamics.Nav.EventSubscription.NavEventScope.CallEventSubscriber(NavEventSubscription subscriber, NavCodeunit subscriberCodeunitInstance, Object[] parameters)
at Microsoft.Dynamics.Nav.EventSubscription.NavEventScope.ProcessCallToAllSubscribers(NavApplicationObjectBase callerApplicationObject, PrepareParametersCallBack prepareParameters)
at Microsoft.Dynamics.Nav.Runtime.NavRecord.ValidateField(Action`1 fieldEvent, NCLMetaField metaField, Boolean isUserInput)
at Microsoft.Dynamics.Nav.Runtime.NavRecord.Validate(NCLMetaField metaField, NavValue newValue, NavRecord callerRecord, Boolean isUserInput)
at Microsoft.Dynamics.Nav.Runtime.NavRecord.Validate(NCLMetaField metaField, NavValue newValue, NavRecord callerRecord)
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit60015.CreateServItemLines_Scope.OnRun()
at Filter.InvokeWithFilter(NavMethodScope )
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit60015.CreateServItemLines(INavRecordHandle ServRegHeader, INavRecordHandle vRecServHeader)
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit60015.WizardFinish_Scope.OnRun()
at Filter.InvokeWithFilter(NavMethodScope )
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit60015.WizardFinish(INavRecordHandle vRecServRegHeader)
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit60015.OnInvoke(Int32 memberId, Object[] args)
at Microsoft.Dynamics.Nav.BusinessApplication.Page60015.FinishWizard_Scope.OnRun()
at Filter.InvokeWithFilter(NavMethodScope )
at Microsoft.Dynamics.Nav.BusinessApplication.Page60015.FinishWizard()
at Filter.InvokeWithFilter(NavMethodScope )
at Microsoft.Dynamics.Nav.BusinessApplication.Page60015.Finish_a45_OnAction()
Source: Microsoft.Dynamics.Nav.Ncl
HResult: -2147467261
If I remove the subscriber, the issue is gone. As soon as I manually re-create it, it crashes again.
There is no code behind the validate of the field. And no real code in the subscriber (it even crashes with 'IF TRUE THEN;').
Any ideas?
Answers
And I'm very much allergic to comments like 'Someone, somewhere, once told me that technology x doesn't work'
I know of one bug related to modifications of object (there can be some I don't know about off cause :-) ):
In NAV 2016/2017 (some or all?) table events stopped to be fired on a table if it had flowfields to another table which was changed. It is quite easy to reproduce.
It was fixed in NAV 2016 CU16 and NAV 2017 CU4.
It is bug ID 203304: "Events stop being triggered after compiling other objects".
It did not trigger an exception, the trigger just stopped calling subscribers... So I dont belive it is related to what you are seeing.
Anyway, if you use table triggers, please make sure to platform upgrade or at least compile all codeunits or restarting the service after changing tables...
http://mibuso.com/blogs/davidmachanick/
A complete database re-compile was the first thing I tried after restarting the service. Still no idea what caused it.