Sync-NavApp ForceSync: Object Reference not set to an instance of an Object
Sync-NavApp -Mode ForceSync fails with "Object Reference not set to an Instance of an Object" when there are breaking changes in the new Version (a few Primary Keys/Fields changed).
Sync-NavApp -Mode Development and Sync-NavApp -Mode Add fail perfectly and state the breaking changes. We know breaking changes are not allowed, but for testing/demo purposes a ForceSync is actually what we want.
This happens since we upgraded from BC19 to BC23 OnPrem.
2. To Reproduce 1.) Publish an App in BC19 2.) Upgrade to BC23 3.) Publish a new Version of the App including breaking changes in BC23 4.) Try to Sync-NavApp with the BC23 NavAdminTool
3. Expected behavior The ForceSync to run sucessfully while purging data in the few Fields connected to the breaking changes. Or at least provide details as of why a Sync with ForceSync could not be done.
4. Actual behavior
Message (NullReferenceException): RootException: NullReferenceException
Object reference not set to an instance of an object.
ExceptionStackTrace:
at Microsoft.Dynamics.Nav.Runtime.Apps.AppTableMetadataHashCalculator.<>c.2.MoveNext()
at System.String.Concat(IEnumerable1 values)
at Microsoft.Dynamics.Nav.Runtime.Apps.AppTableMetadataHashCalculator.ComputeHashForTableChanges(IEnumerable1 changes)
at Microsoft.Dynamics.Nav.Runtime.Apps.SyncRepositoryUpdater.UpdateTrackingRepository(AppSyncContext syncContext, IEnumerable1 changeResults)
at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.SynchronizeTenantDatabaseForAppSyncInternal(NavAppSyncBundle bundle, NavSqlConnectionScope tenantDatabaseScope)
at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.SynchronizeTenantDatabaseForAppSyncInternal(NavAppSyncBundle bundle)
at Microsoft.Dynamics.Nav.Runtime.NavTenant.Microsoft.Dynamics.Nav.Runtime.ITenantSessionHandler.RunTenantActionInSystemSession(Action2 action, Boolean throwExceptions, Boolean useCurrentCulture, Boolean allowAppsDisabledMode, LanguageSetting language, NavCancellationToken cancellationToken)
at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.SynchronizeTenantDatabaseForAppSync(NavAppSyncBundle bundle)
CallerStackTrace:
at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.SynchronizeTenantDatabaseForAppSync(NavAppSyncBundle bundle)
at Microsoft.Dynamics.Nav.Runtime.NavAppSyncManagementTasks.SyncNavAppInternal(NavAppSyncBundle bundle)
at Microsoft.Dynamics.Nav.Runtime.NavSqlTransientErrorHelper.<>c__DisplayClass2_01.1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at CoreWCF.Dispatcher.InvokerUtil.CriticalHelper.<>c__DisplayClass3_0.<GenerateInvokeDelegate>b__0(Object target, Object[] inputs, Object[] outputs)
at CoreWCF.Dispatcher.SyncMethodInvoker.InvokeAsync(Object instance, Object[] inputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass5_0.<Create>b__0(ServiceOperationContext context)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.AddToThreadSchedulerCombinator(ServiceOperationContext context, ServiceOperation innerOperation)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.ErrorMappingCombinator(ServiceOperationContext context, ServiceOperation innerOperation, Boolean useCoreWcfFaultException)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.PartnerTelemetryPermissionErrorCombinator(ServiceOperationContext context, ServiceOperation innerOperation)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.PushPopCombinator(ServiceOperationContext context, ServiceOperation innerOperation, Boolean useCoreWcfFaultException)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.VerifyAdminCombinator(ServiceOperationContext context, ServiceOperation innerOperation, Boolean useCoreWcfFaultException)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.TelemetryCombinator(Category telemetryCategory, Verbosity telemetryVerbosity, ServiceOperationContext context, ServiceOperation innerOperation)
at Microsoft.Dynamics.Nav.Service.ServiceOperationTracer.TraceScopeCombinator(Category telemetryCategory, ServiceOperationContext context, ServiceOperation innerOperation)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.<>c__DisplayClass7_0.<PerformanceCounterCombinator>b__0()
at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationDuration(Stopwatch stopWatch, Action action)
at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationAction(Action action, NavSession session)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.PerformanceCounterCombinator(ServiceOperationContext context, ServiceOperation innerOperation)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.InitClientTelemetryIdsCombinator(ServiceOperationContext context, ServiceOperation innerOperation)
at Microsoft.Dynamics.Nav.Service.ServiceOperationPipeline.TlsClearCombinator(ServiceOperationContext context, ServiceOperation innerOperation)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.InvokeAsync(Object instance, Object[] inputs)
at CoreWCF.Dispatcher.DispatchOperationRuntime.<>c__DisplayClass68_0.<<InvokeAsync>b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at CoreWCF.Dispatcher.DispatchOperationRuntime.<>c__DisplayClass68_0.<InvokeAsync>b__0()
at CoreWCF.Dispatcher.SecurityImpersonationBehavior.RunImpersonated[T](MessageRpc rpc, Func1 func)
at CoreWCF.Dispatcher.DispatchOperationRuntime.InvokeAsync(MessageRpc rpc)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at CoreWCF.Dispatcher.DispatchOperationRuntime.InvokeAsync(MessageRpc rpc)
at CoreWCF.Dispatcher.ImmutableDispatchRuntime.ProcessMessageAsync(MessageRpc rpc)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox1.MoveNext(Thread threadPoolThread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
5. Versions:
- Business Central: BC.12841.DE
Update for future me (or other people): Sync-NavApp -Mode ForceSync seems to be utterly broken in BC23 CU0, Technical Upgrade of the Platform to CU1 resolved the issue.
This was a runtime issue which seems to be fixed in later versions, thus I will be closing this.
We still have the same issue in BC23.3.
Doing a clear schema allows the app to be sync'd but obviously we lose all the data.
Our call stack mentions table bundles rather than metadata.
For others, this turned out to be an entry in the $ndo$navappschemasnapshot table for the Invoice Post. Buffer table on which we had previously had a table extension on. This table has been replaced by the Invoice Posting Buffer table and our table extension had been modified accordingly.
We removed this entry and everything worked as normal