microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
728 stars 241 forks source link

Cannot uninstall an app due to an error: "The application might be incompatible with the current compiler" #7625

Closed spesotskiy closed 6 months ago

spesotskiy commented 8 months ago

1. Describe the bug There are 30+ apps with complex dependencies. They are all correctly installed and work together. But it is not possible to uninstall "Control Addin" app as it throws an error:

The metadata object Table 37077300 was not found for the compiler with emit version 23033.
      The application might be incompatible with the current compiler. Please unpublish the application that contains the application object Table 37077300 and republish it.
      Or, run a technical upgrade of the application database with the 'Force' flag set.

The mentioned object has no connection to the original app.

2. To Reproduce Steps to reproduce the behavior: Actually it was found when we tried to publish a new version of the app during dev process. It failed with a very short and uninformative error: Reason: The Extension cannot be unpublished because it is in use by the following tenants: default We had realized that the uninstall is blocked. So here are steps even without VSCode.

  1. We have all 30+ apps fully installed.
  2. Trying to uninstall "Control Addin" app manually via "Extension Management" page or by running UnInstall-BcContainerApp command
  3. Getting an error pointing to an object, a table, somewhere down in the dependencies tree. Not in the directly connected apps.
  4. Uninstall the app 1 owning that table.
  5. Trying to uninstall "Control Addin" app again.
  6. Getting the same error pointing to another object, a page, in another app.
  7. Uninstall the app 2 owning that page.
  8. Now the "Control Addin" app can be uninstalled. Though after it we need to reinstall 10+ apps that were in the dep tree.

3. Expected behavior Uninstall can be done directly, so no need to uninstall other dependent apps before.

4. Actual behavior

Uninstalling Control Addin from default

      The metadata object Table 37077300 was not found for the compiler with emit version 23033.
      The application might be incompatible with the current compiler. Please unpublish the application that contains the application object Table 37077300 and republish it.
      Or, run a technical upgrade of the application database with the 'Force' flag set.

Exception Script Stack Trace:
at <ScriptBlock>, <No file>: line 25

PowerShell Call Stack:
at Invoke-ScriptInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.2\ContainerHandling\Invoke-ScriptInNavContainer.ps1: line 71
at UnInstall-BcContainerApp, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.2\AppHandling\UnInstall-NavContainerApp.ps1: line 47
at <ScriptBlock>, C:\AdaptiveBS\AJEApps\Scripts\Normal\Lib\AJEAppsMgt.psm1: line 307
at Uninstall-AJEApps, C:\AdaptiveBS\AJEApps\Scripts\Normal\Lib\AJEAppsMgt.psm1: line 307
at <ScriptBlock>, <No file>: line 1

Container Free Physical Memory: 40.2Gb

Services in container BC23:
- MicrosoftDynamicsNavServer$BC is Running
- MSSQL$SQLEXPRESS is Running

Relevant event log from container BC23:
- 20231221 04:26:28 - MicrosoftDynamicsNavServer$BC

  Server instance: BC
  Category: Metadata
  ClientSessionId: 00000000-0000-0000-0000-000000000000
  ClientActivityId: 00000000-0000-0000-0000-000000000000
  ServerSessionUniqueId: 00000000-0000-0000-0000-000000000000
  ServerActivityId: 00000000-0000-0000-0000-000000000000
  EventTime: 12/21/2023 13:26:28
  Message (NavMetadataNotFoundException): RootException: NavMetadataNotFoundException

        The metadata object Table 37077300 was not found for the compiler with emit version 23033.
        The application might be incompatible with the current compiler. Please unpublish the application that contains the application object Table 37077300 and republish it.
        Or, run a technical upgrade of the application database with the 'Force' flag set.

  ExceptionStackTrace:
     at Microsoft.Dynamics.Nav.Runtime.NCLObjectXmlMetadataLoader.GetMetaObjectAsXmlDocument(ApplicationObjectId objectId, NavAppGroup appGroup)
     at Microsoft.Dynamics.Nav.Runtime.NCLObjectMetadataLoaderExtensions.RetrieveRuntimeObject[T](INCLObjectXmlMetadataLoader loader, ObjectType objectType, Int32 objectId, NavAppGroup appGroup, Func`3 exceptWrapperGenerator, Func`2 objectGenerator)
     at Microsoft.Dynamics.Nav.Runtime.NCLObjectMetadataLoaderExtensions.GetMetaTable(INCLObjectXmlMetadataLoader loader, Int32 tableId, NavAppGroup appGroup, Int32 languageAppGroupId)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetaTable.LoadTableMetadata()
     at Microsoft.Dynamics.Nav.Runtime.NCLMetaTable.ValidateMetadata()
     at Microsoft.Dynamics.Nav.Runtime.NCLMetadata.InitializeAppGroupNewObject(NavAppGroup appGroup, NavAppGroupObjectMetadataSummary newObjectSummary, NavAppGroupInitializationType initializationType, ISet`1 targetTypesThatHaveExtensionObjects, Boolean validateMetadata)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetadata.InitializeNewAppObjectsExcept(NavAppGroup appGroup, InitializeAppGroupProfilerSession profilerSession, NavAppGroupInitializationType initializationType, ISet`1 delayedInitializationObjectTypes, ISet`1 targetTypesThatHaveExtensionObjects, Boolean validateMetadata)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetadata.InitializeAppGroupObjects(NavAppGroup appGroup, IReadOnlyList`1 extensionSummariesWeCareAbout, NavAppGroupInitializationType initializationType, Boolean validateMetadata)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetadata.InitializeAppGroup(NavAppGroup appGroup, Boolean initializeOwnedObjectsOnly, Boolean validateMetadata)
  CallerStackTrace:
     at Microsoft.Dynamics.Nav.Runtime.NCLMetadata.InitializeAppGroup(NavAppGroup appGroup, Boolean initializeOwnedObjectsOnly, Boolean validateMetadata)
     at Microsoft.Dynamics.Nav.Runtime.NCLMetadata.InitializeAppGroup(NavAppGroup appGroup, Boolean initializeOwnedObjectsOnly, Boolean validateMetadata)
     at Microsoft.Dynamics.Nav.Runtime.Apps.NavAppGroupUpdater.PrepareAppGroup(NavAppGroup group, NavDiagnostics diagnostics)
     at Microsoft.Dynamics.Nav.Runtime.Apps.NavAppInstaller.PrepareAllAppGroupsForUninstallChain(NavAppUninstallPreCheckHelper precheckResult, NavDiagnostics diagnostics)
     at Microsoft.Dynamics.Nav.Runtime.Apps.NavAppInstaller.Uninstall(NavSqlConnectionScope tenantDatabaseScope, NavSqlDatabaseLock tenantLock, NavAppUninstallPreCheckHelper precheckResult, NavSession session, String name, NavTenant tenant, Boolean doNotSaveData, Boolean clearSchema, String origin, String activityId)
     at Microsoft.Dynamics.Nav.Runtime.NavManagementTasks.<>c__DisplayClass40_0.<UninstallNavAppAndReturnUninstalledDependencies>b__0(NavTenant tenant, NavSession session)
     at Microsoft.Dynamics.Nav.Runtime.NavTenant.Microsoft.Dynamics.Nav.Runtime.ITenantSessionHandler.RunTenantActionInSystemSessionWithoutTransaction(Action`2 action, Boolean throwExceptions, Boolean useCurrentCulture, LanguageSetting language, NavCancellationToken cancellationToken)
     at Microsoft.Dynamics.Nav.Runtime.NavManagementTasks.UninstallNavAppAndReturnUninstalledDependencies(UninstallNavAppArguments uninstallNavAppArguments)
     at Microsoft.Dynamics.Nav.Service.NSAdminService.<>c__DisplayClass58_0.<Microsoft.BusinessCentral.AdminApi.INCLAdminService.UninstallNavApp>b__0(NavSession session)
     at Microsoft.Dynamics.Nav.Service.NSAdminService.<>c__DisplayClass60_0`1.<RunActionOnRequestedTenant>b__0()
     at Microsoft.Dynamics.Nav.Runtime.Apps.NavAppDiagnosticSession.<>c__DisplayClass1_0`1.<SendTraceTagOnFailure>b__0()
     at Microsoft.Dynamics.Nav.Runtime.Apps.NavAppDiagnosticSession.SendTraceTagOnFailure(Action operation, String additionalInfo, Func`2 exceptionMap, String callerName)
     at Microsoft.Dynamics.Nav.Runtime.Apps.NavAppDiagnosticSession.SendTraceTagOnFailure[T](Func`1 operation, String additionalInfo, Func`2 exceptionMap, String callerName)
     at Microsoft.Dynamics.Nav.Service.NSAdminService.Microsoft.BusinessCentral.AdminApi.INCLAdminService.UninstallNavApp(UninstallNavAppArguments uninstallNavAppArguments)
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`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.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.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, Func`1 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.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
     at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

  ProcessId: 29652
  Tag: 000009W
  ThreadId: 1007
  CounterInformation:
  CustomParameters: {
  }
  GatewayCorrelationId:

UnInstall-BcContainerApp Telemetry Correlation Id: 185c8dbc-aa03-4352-b549-ea0c945d3e20
      The metadata object Table 37077300 was not found for the compiler with emit version 23033.
      The application might be incompatible with the current compiler. Please unpublish the application that contains t
he application object Table 37077300 and republish it.
      Or, run a technical upgrade of the application database with the 'Force' flag set.

At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.2\ContainerHandling\Invoke-ScriptInNavContainer.ps1
:112 char:13
+             throw $errorMessage
+             ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (
      The met...flag set.
    :String) [], RuntimeException
    + FullyQualifiedErrorId :
      The metadata object Table 37077300 was not found for the compiler with emit version 23033.
          The application might be incompatible with the current compiler. Please unpublish the application that conta
   ins the application object Table 37077300 and republish it.
      Or, run a technical upgrade of the application database with the 'Force' flag set.

5. Versions:

kalberes commented 6 months ago

This is a runtime issue. Besides, without a clear repro there is not much to do. Official answer: image