Event subscriber crash not caught by NAV

EvREvR Member Posts: 178
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.
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?


  • JumpingjfJumpingjf Member Posts: 5
    Someone say me that Events in 2016 don't works fine. The solution maybe restarts the services after any modification in objects.
  • EvREvR Member Posts: 178
    Nope. Restarting the service makes no difference. Recompiling the entire application doesn't either.
    And I'm very much allergic to comments like 'Someone, somewhere, once told me that technology x doesn't work' ;)
  • lyngelynge Member Posts: 85
    I agree - and I can add some facts :-)
    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...
  • davmac1davmac1 Member Posts: 1,283
    importing objects (typically from a dev database to production) without recompiling can cause this problem - do a F11 recompile
  • EvREvR Member Posts: 178
    It was an object that has been in the database for ages, and the subscriber has always worked before.
    A complete database re-compile was the first thing I tried after restarting the service. Still no idea what caused it.
Sign In or Register to comment.