AL icon indicating copy to clipboard operation
AL copied to clipboard

error AL0999: Internal error: System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)

Open yishengcao opened this issue 2 years ago • 2 comments

I am upgrading BC14 on-premises to BC20 on-premises. After exporting C/AL code and converting them to AL files by using the Txt2AL tool, I tried to compile the Base Application. But the following error blocked me.

`Microsoft (R) AL Compiler version 9.2.9.49526 Copyright (C) Microsoft Corporation. All rights reserved

Compilation started for project 'My Base Application' containing '6388' files at '04:17:59.602'.

error AL0999: Internal error: System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilExtensions.ImportTypeDefinition(ModuleDefinition module, Type t) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\Cecil\CecilExtensions.cs:line 39 at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeInfoProvider..ctor(ReaderParameters moduleReaderParameters) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\Cecil\CecilDotNetTypeInfoProvider.cs:line 128 at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeInfoProvider.Create(ReaderParameters moduleReaderParameters) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\Cecil\CecilDotNetTypeInfoProvider.cs:line 118 at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeLoader.CreateTypeInfoProvider() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\Cecil\CecilDotNetTypeLoader.cs:line 139 at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeLoader.get_TypeInfoProvider() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\Cecil\CecilDotNetTypeLoader.cs:line 48 at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeLoader.<LoadAssembly>b__13_0(String assemblyName) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\Cecil\CecilDotNetTypeLoader.cs:line 68 at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeLoader.LoadAssembly(String fullAssemblyName) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\Cecil\CecilDotNetTypeLoader.cs:line 64 at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.DotNetResolver.LoadAssembly(String fullAssemblyName) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DotNet\DotNetResolver.cs:line 31 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceDotNetAssemblySymbol.<LazyGetAssembly>b__33_0(DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceDotNetAssemblySymbol.cs:line 226 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.Symbol.LazySetSymbol(Action1 setSymbol, CompletionPart completionValue, SymbolCompletionState& state) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Symbol.cs:line 572 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceDotNetAssemblySymbol.LazyGetAssembly() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceDotNetAssemblySymbol.cs:line 214 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceDotNetAssemblySymbol.get_AssemblyInfo() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceDotNetAssemblySymbol.cs:line 52 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceDotNetTypeDeclarationSymbol.<LazyGetType>b__26_0(DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceDotNetTypeDeclarationSymbol.cs:line 125 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.Symbol.LazySetSymbol(Action1 setSymbol, CompletionPart completionValue, SymbolCompletionState& state) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Symbol.cs:line 572 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceDotNetTypeDeclarationSymbol.LazyGetType() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceDotNetTypeDeclarationSymbol.cs:line 123 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceDotNetTypeDeclarationSymbol.get_DotNetType() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceDotNetTypeDeclarationSymbol.cs:line 55 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ModuleSymbol.GetObjectSymbolByName(ImmutableDictionary2 objectsByName, SymbolKind kind, String name) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\ModuleSymbol.cs:line 386 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceModuleSymbol.GetObjectSymbolByName(SymbolKind kind, String name) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceModuleSymbol.cs:line 1353 at Microsoft.Dynamics.Nav.CodeAnalysis.ReferenceManager.ResolveDotNetObjectSymbolsByName(ModuleSymbol referencingModule, String name) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\ReferenceManager.cs:line 364 at Microsoft.Dynamics.Nav.CodeAnalysis.ReferenceManager.GetObjectSymbolsByNameAcrossModules(ModuleSymbol referencingModule, SymbolKind kind, String name) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\ReferenceManager.cs:line 330 at Microsoft.Dynamics.Nav.CodeAnalysis.Binder.GetApplicationObjectTypeSymbols(ObjectNameOrIdSyntax objectNameOrId, SymbolKind kind) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:line 321 at Microsoft.Dynamics.Nav.CodeAnalysis.Binder.GetSubtypedDataType(SubtypedDataTypeSyntax syntax, SymbolKind kind, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:line 303 at Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindSubTypedDataType(Symbol ownerSymbol, SubtypedDataTypeSyntax syntax, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:line 289 at Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindType(Symbol ownerSymbol, DataTypeSyntax syntax, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:line 108 at Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindVariableOrParameterType(Symbol ownerSymbol, TypeReferenceBaseSyntax syntax, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:line 490 at Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindVariableType(Symbol ownerSymbol, TypeReferenceBaseSyntax syntax, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:line 420 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceVariableSymbol.LazyGetType() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceVariableSymbol.cs:line 107 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceVariableSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceVariableSymbol.cs:line 126 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ObjectMembers1.ForceMembersCompleteAndCheckUniqueness(SourceLocation locationOpt, DiagnosticBag diagnostics, CancellationToken cancellationToken, Predicate1 excludeFromNameUniqueness) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Members\ObjectMembers.cs:line 175 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ObjectMembers1.ForceCompleteMembers(SourceLocation locationOpt, CancellationToken cancellationToken, Predicate1 excludeFromNameUniqueness) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Members\ObjectMembers.cs:line 1040 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ObjectMembers1.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken, Predicate1 excludeFromNameUniqueness) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Members\ObjectMembers.cs:line 990 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceCodeunitTypeSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceCodeunitTypeSymbol.cs:line 52 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceModuleSymbol.ForceCompleteMemberByLocation(SourceLocation locationOpt, Symbol member, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceModuleSymbol.cs:line 223 at System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location --- at System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica.Execute() --- End of inner exception stack trace --- at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction1 action, ParallelOptions options, Boolean stopOnFirstFailure) at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally) --- End of stack trace from previous location --- at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException) at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally) at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body) at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceModuleSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceModuleSymbol.cs:line 101 at Microsoft.Dynamics.Nav.CodeAnalysis.Compilation.GetSourceDeclarationDiagnostics(SyntaxTree syntaxTree, Nullable1 filterSpanWithinTree, Func`4 locationFilterOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\Compilation.cs:line 1084 at Microsoft.Dynamics.Nav.CodeAnalysis.Compilation.GetDiagnostics(CompilationStage stage, Boolean includeEarlierStages, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\Compilation.cs:line 680

Compilation ended at '04:17:59.631'.

Error: The package could not be created. `

Please help me to indicate where is wrong.

yishengcao avatar Jun 21 '22 05:06 yishengcao

Add some information, the operation is following with this guide: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/upgrade/devenv-code-conversion

And the issue is happen when running step 11 of Task 7.

yishengcao avatar Jun 22 '22 03:06 yishengcao

This issue happened due to you need to change assemblyProbingPath to only include the Service assemblies in the setting. Json to be "C:\Program Files\Microsoft Dynamics 365 Business Central\200\Service",

"al.assemblyProbingPaths": [

        "C:\\Program Files\\Microsoft Dynamics 365 Business Central\\200\\Service",

        "C:\\Program Files (x86)\\Microsoft Dynamics 365 Business Central\\200\\RoleTailored Client",

        "C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8"

IBakr avatar Oct 11 '22 12:10 IBakr

I was experiencing the same error. I did check on my setting.json but it was all ok. I was working on BC190 so since I had several project on that version it had same problem but peoject on different version were ok. I uninstall my BC190 and reintalled it a fresh(Make sure you have deleted the BC190 folder on business central folders before reinstalling it again on program files and Program Files(x86)). @yishengcao try this.

Colloture avatar Dec 02 '22 10:12 Colloture

Resolving this issue as it seemed to have been caused by a configuration issue with the assembly probing paths.

qutreson avatar Dec 29 '22 09:12 qutreson