C# compilation has failed for the application object Report
Hello, everyone!
In one of our customer projects we get the following compilation error when executing several reports.
The error only occurs in the customer system, not in our test environment or via Docker. Reinstallation did not change anything.
Any ideas on this?
kind regards, Sebastian
-- Server instance: BC_Test Tenant ID: Environment Name: Environment Type: User: Type: System.InvalidOperationException Message: C# compilation has failed for the application object Report_5020394. The failing c# file name is A43570CF3CBCC3FB2E40F572637C2B44B7F3C33244CE07FF3D26AA759635E1E7.cs. You can find this file with the associated AL file saved in the C:\ProgramData\Microsoft\Microsoft Dynamics NAV\180\Server\MicrosoftDynamicsNavServer$BC_Test\apps\compilationerrors folder. Detailed compilation error: C:\ProgramData\Microsoft\Microsoft Dynamics NAV\180\Server\MicrosoftDynamicsNavServer$BC_Test\apps\metadata\3\A4\A43570CF3CBCC3FB2E40F572637C2B44B7F3C33244CE07FF3D26AA759635E1E7.cs(55,18): error CS1501: No overload for method 'Add' takes 2 arguments C:\ProgramData\Microsoft\Microsoft Dynamics NAV\180\Server\MicrosoftDynamicsNavServer$BC_Test\apps\metadata\3\A4\A43570CF3CBCC3FB2E40F572637C2B44B7F3C33244CE07FF3D26AA759635E1E7.cs(56,18): error CS1501: No overload for method 'Add' takes 2 arguments
StackTrace:
bei Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args, Boolean resolveHandler, Boolean throwOnNotFound)
bei Microsoft.Dynamics.Nav.Runtime.NavForm.RaiseOnAction(Nullable1 actionId, String actionTriggerMethodName)
bei Microsoft.Dynamics.Nav.Service.NSField.<>c__DisplayClass20_0.<ActionField>b__0(NsDataAccess recDataAccess)
bei Microsoft.Dynamics.Nav.Service.NsFormDataAccess.RunWithFormDataAccess[T](ITreeObject parent, NavForm form, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NsDataAccess.RunWithDataAccess[T](ITreeObject parent, NavRecordState state, Boolean instantiateNewForm, Guid parentFormHandle, String parentControlName, Boolean& instantiatedForm, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NsDataAccess.RunWithDataAccess[T](ITreeObject parent, NavRecordState state, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NSField.Action(NavSession session)
bei SyncInvokeActionField(Object , Object[] , Object[] )
bei System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.RunInTransactionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass28_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.TransientErrorRetryCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass28_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.ErrorMappingCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
Source: Microsoft.Dynamics.Nav.Ncl
HResult: -2146233079
StackTrace:
bei Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args, Boolean resolveHandler, Boolean throwOnNotFound)
bei Microsoft.Dynamics.Nav.Runtime.NavForm.RaiseOnAction(Nullable1 actionId, String actionTriggerMethodName)
bei Microsoft.Dynamics.Nav.Service.NSField.<>c__DisplayClass20_0.<ActionField>b__0(NsDataAccess recDataAccess)
bei Microsoft.Dynamics.Nav.Service.NsFormDataAccess.RunWithFormDataAccess[T](ITreeObject parent, NavForm form, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NsDataAccess.RunWithDataAccess[T](ITreeObject parent, NavRecordState state, Boolean instantiateNewForm, Guid parentFormHandle, String parentControlName, Boolean& instantiatedForm, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NsDataAccess.RunWithDataAccess[T](ITreeObject parent, NavRecordState state, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NSField.Action(NavSession session)
bei SyncInvokeActionField(Object , Object[] , Object[] )
bei System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.RunInTransactionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass28_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.TransientErrorRetryCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass28_1.b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.ErrorMappingCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
1 actionId, String actionTriggerMethodName)
bei Microsoft.Dynamics.Nav.Service.NSField.<>c__DisplayClass20_0.<ActionField>b__0(NsDataAccess recDataAccess)
bei Microsoft.Dynamics.Nav.Service.NsFormDataAccess.RunWithFormDataAccess[T](ITreeObject parent, NavForm form, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NsDataAccess.RunWithDataAccess[T](ITreeObject parent, NavRecordState state, Boolean instantiateNewForm, Guid parentFormHandle, String parentControlName, Boolean& instantiatedForm, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NsDataAccess.RunWithDataAccess[T](ITreeObject parent, NavRecordState state, Func2 func)
bei Microsoft.Dynamics.Nav.Service.NSField.Action(NavSession session)
bei SyncInvokeActionField(Object , Object[] , Object[] )
bei System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.RunInTransactionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
bei Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass28_1.Type: System.Reflection.TargetInvocationException Message: Ein Aufrufziel hat einen Ausnahmefehler verursacht. StackTrace: bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) bei Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args, Boolean resolveHandler, Boolean throwOnNotFound) Source: mscorlib HResult: -2146232828 StackTrace: bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) bei Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args, Boolean resolveHandler, Boolean throwOnNotFound)
Type: System.InvalidOperationException Message: C# compilation has failed for the application object Report_5020394. The failing c# file name is A43570CF3CBCC3FB2E40F572637C2B44B7F3C33244CE07FF3D26AA759635E1E7.cs. You can find this file with the associated AL file saved in the C:\ProgramData\Microsoft\Microsoft Dynamics NAV\180\Server\MicrosoftDynamicsNavServer$BC_Test\apps\compilationerrors folder. Detailed compilation error: C:\ProgramData\Microsoft\Microsoft Dynamics NAV\180\Server\MicrosoftDynamicsNavServer$BC_Test\apps\metadata\3\A4\A43570CF3CBCC3FB2E40F572637C2B44B7F3C33244CE07FF3D26AA759635E1E7.cs(55,18): error CS1501: No overload for method 'Add' takes 2 arguments C:\ProgramData\Microsoft\Microsoft Dynamics NAV\180\Server\MicrosoftDynamicsNavServer$BC_Test\apps\metadata\3\A4\A43570CF3CBCC3FB2E40F572637C2B44B7F3C33244CE07FF3D26AA759635E1E7.cs(56,18): error CS1501: No overload for method 'Add' takes 2 arguments
StackTrace:
bei Microsoft.Dynamics.Nav.Runtime.Apps.NavAppClrTypeRetriever.LogErrorsAndThrowException(ApplicationObjectId objectId, String csharpCodePath, String compilationResult)
bei Microsoft.Dynamics.Nav.Runtime.Apps.NavAppClrTypeRetriever.GetClrType(RuntimePackageId runtimePackageId, ApplicationObjectId objectId)
bei Microsoft.Dynamics.Nav.Runtime.NCLMetaApplicationObject.CompileAndLoadClrObject()
bei Microsoft.Dynamics.Nav.Runtime.NCLMetadata.GetMetaApplicationObjectInternal(ApplicationObjectId appObjectId, Boolean requireCompiled, Boolean onlySearchCache, Int32 appGroupId)
bei Microsoft.Dynamics.Nav.Runtime.NCLMetadata.GetMetaApplicationObject(ApplicationObjectId appObjectId, Int32 appGroupId, Boolean requireCompiled, Boolean onlySearchCache)
bei Microsoft.Dynamics.Nav.Runtime.NCLMetadata.GetMetaReportById(Int32 reportId, Int32 appGroupId, Boolean requireCompiled)
bei Microsoft.Dynamics.Nav.Runtime.NavReport.RunReport(Int32 reportId, Nullable1 requestWindow, Nullable1 systemPrinter, NavRecord record, ReportRunMode runMode)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.PrintReport_Scope_771412007.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.PrintReport(Int32 reportUsage, NavCode customerNo)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.MoveOrderPrint_Deposit_Scope__559872981.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.MoveOrderPrint_Deposit(INavRecordHandle stockDepositHeader2)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.OnInvoke(Int32 memberId, Object[] args)
bei Microsoft.Dynamics.Nav.BusinessApplication.Record5020385.PrintMoveOrderList_Scope_2060041512.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Record5020385.PrintMoveOrderList()
bei Microsoft.Dynamics.Nav.BusinessApplication.Record5020385.OnInvoke(Int32 memberId, Object[] args)
bei Microsoft.Dynamics.Nav.BusinessApplication.Page5020350.Move_Order_List_a45_OnAction_Scope.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Page5020350.Move_Order_List_a45_OnAction()
Source: Microsoft.Dynamics.Nav.Ncl
HResult: -2146233079
StackTrace:
bei Microsoft.Dynamics.Nav.Runtime.Apps.NavAppClrTypeRetriever.LogErrorsAndThrowException(ApplicationObjectId objectId, String csharpCodePath, String compilationResult)
bei Microsoft.Dynamics.Nav.Runtime.Apps.NavAppClrTypeRetriever.GetClrType(RuntimePackageId runtimePackageId, ApplicationObjectId objectId)
bei Microsoft.Dynamics.Nav.Runtime.NCLMetaApplicationObject.CompileAndLoadClrObject()
bei Microsoft.Dynamics.Nav.Runtime.NCLMetadata.GetMetaApplicationObjectInternal(ApplicationObjectId appObjectId, Boolean requireCompiled, Boolean onlySearchCache, Int32 appGroupId)
bei Microsoft.Dynamics.Nav.Runtime.NCLMetadata.GetMetaApplicationObject(ApplicationObjectId appObjectId, Int32 appGroupId, Boolean requireCompiled, Boolean onlySearchCache)
bei Microsoft.Dynamics.Nav.Runtime.NCLMetadata.GetMetaReportById(Int32 reportId, Int32 appGroupId, Boolean requireCompiled)
bei Microsoft.Dynamics.Nav.Runtime.NavReport.RunReport(Int32 reportId, Nullable1 requestWindow, Nullable1 systemPrinter, NavRecord record, ReportRunMode runMode)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.PrintReport_Scope_771412007.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.PrintReport(Int32 reportUsage, NavCode customerNo)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.MoveOrderPrint_Deposit_Scope__559872981.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.MoveOrderPrint_Deposit(INavRecordHandle stockDepositHeader2)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit5020309.OnInvoke(Int32 memberId, Object[] args)
bei Microsoft.Dynamics.Nav.BusinessApplication.Record5020385.PrintMoveOrderList_Scope_2060041512.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Record5020385.PrintMoveOrderList()
bei Microsoft.Dynamics.Nav.BusinessApplication.Record5020385.OnInvoke(Int32 memberId, Object[] args)
bei Microsoft.Dynamics.Nav.BusinessApplication.Page5020350.Move_Order_List_a45_OnAction_Scope.OnRun()
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Page5020350.Move_Order_List_a45_OnAction()
Should probably post this if you can get it:
The failing c# file name is A43570CF3CBCC3FB2E40F572637C2B44B7F3C33244CE07FF3D26AA759635E1E7.cs. You can find this file with the associated AL file saved in the C:\ProgramData\Microsoft\Microsoft Dynamics NAV\180\Server\MicrosoftDynamicsNavServer$BC_Test\apps\compilationerrors folder.
Good point:

Also missing are AL code and steps to reproduce the problem (just try to run the report request page, I guess?) and info on what versions of AL compiler and BC you use.
Server is 18.0.22893, AL Compiler 7.0. The error occurs with every report in our ISV number range.
Are you by any chance using the Get-NavAppRuntimePackage command to get the .app file from your instance and sending that to the customer? If so, you need to use the same version of BC that the customer system is running.
The explanation here is that runtime packages are different from regular .app files (ones compiled from VSCode) in that they are not recompiled on the server but the compiled C# is bundled as part of the .app file. This means that if the C# emit is different between the version of BC where the .app is taken from, and the .app is installed then the installation may fail. Because of this, it's important to use the same versions of BC when using runtime packages. (of course, alternatively you can use regular .app packages to not have to deal with this, but then you lose the ability to not bundle .al code that you get with runtime packages)
If you are not using Get-NavAppRuntimePackage, can you get a minimal repro? This really looks like a mismatch between compiler versions, since the .Add was modified (in 18.1 I think?) to support report extensions.