AL
AL copied to clipboard
Internal error when loading a workspace for a modified base app
1. Describe the bug I try to open a workspace with a modified base application locally, but get an internal error and don't know where to start looking for possible
2. To Reproduce Steps to reproduce the behavior:
- Create a Docker container with the right version, based on a .bak file of our product
- Clone the sources from our repo
- Get folders Service, Reference Assemblies and C:\Program Files\dotnet\ from the container and put them into .netpackages (that fixes all errors about missing dotnet components)
- Restart VS Code, the message "Loading workspace: Preparing project: '4PSConstructNL'" appears
3. Expected behavior The workspace should successfully load or give me a meaningful error message what is missing
4. Actual behavior I get the following error:
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.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 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.ReferenceDotNetAssemblyDeclarationSymbol.GetAssemblyInfoLazy() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferenceDotNetAssemblyDeclarationSymbol.cs:line 69
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferenceDotNetAssemblyDeclarationSymbol.<.ctor>b__4_0() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferenceDotNetAssemblyDeclarationSymbol.cs:line 35
at System.Lazy`1.PublicationOnlyViaFactory(LazyHelper initializer)
at System.Lazy`1.CreateValue()
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferenceDotNetAssemblyDeclarationSymbol.get_AssemblyInfo() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferenceDotNetAssemblyDeclarationSymbol.cs:line 49
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferenceDotNetTypeDeclarationSymbol.GetDotNetTypeSymbolLazy(DotNetTypeDeclarationDefinition typeDefinition) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferenceDotNetTypeDeclarationSymbol.cs:line 65
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferenceDotNetTypeDeclarationSymbol.<>c__DisplayClass5_0.<.ctor>b__0() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferenceDotNetTypeDeclarationSymbol.cs:line 33
at System.Lazy`1.PublicationOnlyViaFactory(LazyHelper initializer)
at System.Lazy`1.CreateValue()
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferenceDotNetTypeDeclarationSymbol.get_DotNetType() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferenceDotNetTypeDeclarationSymbol.cs:line 48
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ModuleSymbol.GetObjectSymbolByName(ImmutableDictionary`2 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.ReferenceManager.ResolveDotNetObjectSymbolsByName(ModuleSymbol referencingModule, String name) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\ReferenceManager.cs:line 361
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.BindParameterType(Symbol ownerSymbol, TypeReferenceBaseSyntax syntax, Boolean isVar, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:line 466
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ParameterHelpers.MakeParameters(Binder binder, Symbol owner, SeparatedSyntaxList`1 syntax, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\ParameterHelpers.cs:line 22
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceMethodOrTriggerSymbol.LazyGetParameters(MethodOrTriggerDeclarationSyntax syntax, Binder signatureBinder, DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceMethodOrTriggerSymbol.cs:line 443
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceMethodOrTriggerSymbol.ParametersChecks(DiagnosticBag diagnostics) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceMethodOrTriggerSymbol.cs:line 419
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceMethodOrTriggerSymbol.LazyMethodChecks() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceMethodOrTriggerSymbol.cs:line 250
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceMethodOrTriggerSymbol.get_ReturnValue() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceMethodOrTriggerSymbol.cs:line 403
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.MethodSymbol.get_ReturnType() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\MethodSymbol.cs:line 39
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceAttributeSymbol.CheckAttribute() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceAttributeSymbol.cs:line 312
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceAttributeSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceAttributeSymbol.cs:line 277
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceMethodOrTriggerSymbol.ForceCompleteAttributes(SourceLocation locationOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceMethodOrTriggerSymbol.cs:line 370
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceMethodOrTriggerSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceMethodOrTriggerSymbol.cs:line 304
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ObjectMembers`1.ForceMembersCompleteAndCheckUniqueness(SourceLocation locationOpt, DiagnosticBag diagnostics, CancellationToken cancellationToken, Predicate`1 excludeFromNameUniqueness) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Members\ObjectMembers.cs:line 175
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ObjectMembers`1.ForceCompleteMembers(SourceLocation locationOpt, CancellationToken cancellationToken, Predicate`1 excludeFromNameUniqueness) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Members\ObjectMembers.cs:line 1040
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ObjectMembers`1.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken, Predicate`1 excludeFromNameUniqueness) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Members\ObjectMembers.cs:line 990
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceTableTypeSymbol.ForceComplete(SourceLocation locationOpt, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceTableTypeSymbol.cs:line 50
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_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<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](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 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, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 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, Nullable`1 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
5. Versions:
- AL Language: v9.0.605172
- Visual Studio Code: 1.66.0 (user setup)
- Business Central: 19.1 onprem nl
- List of Visual Studio Code extensions that you have installed: A lot, but all disabled when reproducing this problem
Final Checklist
Please remember to do the following:
-
[X] Search the issue repository to ensure you are reporting a new issue
-
[X] Reproduce the issue after disabling all extensions except the AL Language extension
-
Simplify your code around the issue to better isolate the problem --> Don't know what to do there...
@tfenster - can we get a more minimal repro for this?
@thloke I have no idea how I would narrow it down. Compiling works for a regular extension but gives this error for the base app. How would I even try to find out how I can narrow it down? Any ideas?
Looks like a dotnet reference resolution problem for a dotnet type used in AL. Probably loading mscorlib.
@thloke @kalberes any ideas how I can find out what the root cause for this problem is?
@tfenster You could also share your whole repository (not publicly here on GitHub, of course). I did that a couple of times earlier as well.
Happy to do that if @thloke or @kalberes would take a look
@thloke, I have a similar issue again. I have:
- set up a clean VM
- installed VS Code and the AL extension
- checked out our modified base app
- downloaded symbols
- got the DLLs from a fresh container
When I then open the workspace, for a very long time I see
After ~ 20 minutes, I get
The AL extension output shows ~ 10 times this
Any ideas? I'd be happy to give you access to the repro VM or privately share the workspace with you. I have used both the current AL extension release and the latest pre-release, same behaviour
@tfenster
We do have the same problem with our baseapp. We cant package it with the same stack overflow in the cecil-thingie, The problem is still there in BC 22 CU 3
our workaround is to set the assembly probing path in vs code to exact this 3 and throw away all other probing pathes.
"C:/Program Files/dotnet/shared/Microsoft.AspNetCore.App/6.0.18", "C:/Program Files/dotnet/shared/Microsoft.NETCore.App/6.0.18", "C:/Program Files/Microsoft Dynamics 365 Business Central/220/Service"
Cave: the order of the assembly probing pathes is relevant and must not be changed!!!
Also we do press the button cancel on the "loading workspace - preparing project"- message
it seems to me that the Al Language extension parse to much files/dotnet components and an internal array flows over
P.S.: Also Greetings to David F., I hope he likes his new job,we miss him here
@kalberes @qutreson Any update on this? Can I do anything to help?
@tfenster Microsoft Support contacted me today regarding the support case i opened with link to the issue I provided the information that it started first with BC 22 when packaging a baseapp. Before with BC 21 and earlier it worked fine to package a baseapp
@MBGWS thanks for sharing, then maybe we'll see some progress :)
@tfenster Issue will be solved in a minor Update of BC 22, hopefully the next
Issue is solved with BC 22 CU 6 OnPrem (Build 22.0.60864.0)
With the Workspace-Path set to "al.assemblyProbingPaths": [ "C:/Program Files/dotnet/shared/Microsoft.AspNetCore.App/6.0.22", "C:/Program Files/dotnet/shared/Microsoft.NETCore.App/6.0.22", "C:/Program Files/Microsoft Dynamics 365 Business Central/220/Service" ]
our Baseapps are packaged successfully everytime
@MBGWS - Thank you for confirming the issue is fixed.
@tfenster - Is the issue also resolved for you?
yes! I didn't try with 22, but 23 works and that is good enough for me. Thanks