Al: textDocument/completion' failed with error:'The object reference was not set to an object instance.''

Created on 15 Jun 2018  ·  18Comments  ·  Source: microsoft/AL

I am working on an Extension which should be added to the AppSource. To achieve this I need to build a test Extension. But in my test Extension I get this error message when I try to use IntelliSense in the test procedure.

Processing of message 'textDocument/completion' failed with error: 'Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.'
StackTrace:
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ResolveApplicationObjectReference(ModuleSymbol module, SymbolKind kind, Subtype subType) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:Zeile 707.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ResolveElementType(ModuleSymbol module, Symbol owner, TypeDefinition typeDefinition) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:Zeile 804.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SymbolReference.SerializableSymbolModelConverter.ResolveType(ModuleSymbol module, Symbol owner, TypeDefinition typeDefinition) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolReference\SerializableSymbolModelConverter.cs:Zeile 76.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferenceGlobalVariableSymbol..ctor(ContainerSymbol containingSymbol, VariableDefinition variable) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferenceGlobalVariableSymbol.cs:Zeile 22.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferencePageTypeSymbol.<LazyGetMembers>b__30_0(VariableDefinition f) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferencePageTypeSymbol.cs:Zeile 147.
   bei System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   bei System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   bei System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   bei System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferencePageTypeSymbol.LazyGetMembers() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferencePageTypeSymbol.cs:Zeile 147.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.ReferencePageTypeSymbol.GetMembers() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Reference\ReferencePageTypeSymbol.cs:Zeile 80.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SymbolExtensions.GetMembersOfKind[T](ContainerSymbol symbol, SymbolKind kind) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\KindsAndExtensions\SymbolExtensions.cs:Zeile 1097.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.PageTypeSymbol.<.ctor>b__1_0() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\PageTypeSymbol.cs:Zeile 30.
   bei System.Lazy`1.CreateValue()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Lazy`1.get_Value()
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.TestPageTypeSymbol..ctor(Symbol containingSymbol, PageTypeSymbol pageTypeSymbol) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\BuiltIn\TestPageTypeSymbol.cs:Zeile 32.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindSubTypedDataType(Symbol ownerSymbol, SubtypedDataTypeSyntax syntax, DiagnosticBag diagnostics) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:Zeile 224.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindType(Symbol ownerSymbol, DataTypeSyntax syntax, DiagnosticBag diagnostics) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:Zeile 48.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindVariableOrParameterType(Symbol ownerSymbol, TypeReferenceBaseSyntax syntax, DiagnosticBag diagnostics) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:Zeile 377.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Binder.BindVariableType(Symbol ownerSymbol, TypeReferenceBaseSyntax syntax, DiagnosticBag diagnostics) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Binder\Binder_Symbols.cs:Zeile 326.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SourceVariableSymbol.LazyGetType() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceVariableSymbol.cs:Zeile 119.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SourceVariableSymbol.get_Type() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Source\SourceVariableSymbol.cs:Zeile 76.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.VisitVariable(VariableSymbol symbol) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:Zeile 172.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplay.ToDisplayParts(ISymbol symbol, SemanticModel semanticModelOpt, Int32 positionOpt, SymbolDisplayFormat format, Boolean minimal) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplay.cs:Zeile 131.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Symbol.ToDisplayParts(SymbolDisplayFormat format) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Symbol.cs:Zeile 491.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.SymbolCompletionItem.Create(String displayText, TextSpan span, IReadOnlyList`1 symbols, Int32 contextPosition, Int32 descriptionPosition, String sortText, String insertionText, Nullable`1 glyph, String filterText, Boolean preselect, SupportedPlatformData supportedPlatforms, Boolean isArgumentName, ImmutableDictionary`2 properties, ImmutableArray`1 tags, CompletionItemRules rules) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\SymbolCompletionItem.cs:Zeile 63.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItem(String displayText, String insertionText, Int32 position, List`1 symbols, AbstractSyntaxContext context, TextSpan span, Boolean preselect, SupportedPlatformData supportedPlatformData) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:Zeile 112.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItem(String displayText, String insertionText, Int32 position, List`1 symbols, AbstractSyntaxContext context, TextSpan span, Dictionary`2 invalidProjectMap, List`1 totalProjects, Boolean preselect) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:Zeile 107.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.<>c__DisplayClass5_0.<CreateItems>b__3(IGrouping`2 g) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:Zeile 48.
   bei System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   bei System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   bei System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItems(Int32 position, IEnumerable`1 symbols, TextSpan span, AbstractSyntaxContext context, Dictionary`2 invalidProjectMap, List`1 totalProjects, Boolean preselect) in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:Zeile 45.
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.<GetItemsWorkerAsync>d__14.MoveNext() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:Zeile 194.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.<ProvideCompletionsAsync>d__13.MoveNext() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:Zeile 174.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.CompletionServiceWithProviders.<GetContextAsync>d__24.MoveNext() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\CompletionServiceWithProviders.cs:Zeile 369.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.CompletionServiceWithProviders.<GetCompletionsAsync>d__17.MoveNext() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\CompletionServiceWithProviders.cs:Zeile 186.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.CompletionRequestHandler.<HandleAsync>d__4.MoveNext() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\CompletionRequestHandler.cs:Zeile 42.
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei Microsoft.Dynamics.Nav.EditorServices.Protocol.RequestRegistry.<Process>d__6.MoveNext() in C:\a\36\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Endpoints\RequestRegistry.cs:Zeile 59.

I am working with the newest AL Language Version (0.12.17091).

investigate

Most helpful comment

Assuming you mean @OlivierHellmann

All 18 comments

Hi @OlivierHellmann, the current extension on VS Code marketplace is 0.15.18771, can you try with this version and verify if the stack trace also reproduces with this version?

@qutreson just tried the marketplace version and got the exact same error

@oliverkeller can you provide us with a sample of code that we could use in order to reproduce the IntelliSense issue? So that we know in which context triggering IntelliSense can lead to this stacktrace.

Assuming you mean @OlivierHellmann

Exactly, sorry!

@qutreson here is the sample

App.json Extension.txt
App.json Test Extension.txt
Test Codeunit.txt.txt

I also get a similar error when i try to work with records
Test Codeunit2.txt

Thank you @OlivierHellmann.

I created an extension using the first app.json you provided with a simple table MySetup and a simple page MySetupWizard. I then created a test extension using the second app.json, but when triggering IntelliSense, I did not get any error. I couldn't reproduce it using the extension from the market place (0.15.18771) and on our latest master. I guess I might be missing something to reproduce it.

Is there something particular in the page MySetupWizard or in the Table MySetup? Can you reproduce it when using only these files?

I get the same error out of the sudden. Yesterday I could create my Extension package without any problem, today I get the same error as Oliver.

Please note that this issue should not prevent you from creating your package. From what I can read from the stack trace, this issue happens when requesting autocomplete when coding.

Hi @DominikDitoIvosevic - the Package is created but only got 1kb of size. When you open the .app file with 7zip it includes nothing.
I just found out how to resolve my problem. I created a new Codeunit - not related to any records, just for displaying some dialogs.
When I remove the codeunit the package can be created without any problems.

Not sure what's the matter in this codeunit.
I'll investigate and tell if I find anything..

Update - I found the reason which forces the compiler to crash (in my example).
I'm using an array of dialog, the related issue can be found here: #2689

@qutreson sorry for the late response. I couldn't recreate this message with just the sample so I was digging and I found the I had a global record variable and later the same record as a local variable, after I removed the global it worked. I don't really know if that was the problem but it works now.

I tried to reproduce the error by adding a global variable of a record and a local variable of the same record, but it did not reproduce the error. Do you remember which record it was? Or, better, do you have some code that I could use in order to try to reproduce it?

@qutreson I have to apologize, I was too fast. The Problem wasn't a global and a local variable, I digged some more and found that the Problem was a dead page variable.

TestCodeunit.txt
PageListPart.txt
TableAnswer.txt

Hi @OlivierHellmann, no problem :). The error stack you are getting is due to IntelliSense, does it happens wherever you try to trigger it or does it happen only at some specific places in your test codeunit? If so, where? I just tried trigger IntelliSense here and there in the test codeunit using the latest extension from the marketplace (now, 0.16.16948) and couldn't reproduce the issue. Does it still reproduce for you with this version of the extension?
Also, in the al files you uploaded, there is a reference to a Record OLI Question, is there something specific in this record?

@qutreson i just tried it with the 0.16.16948 and couldn't reproduce it aswell.
Also tried with the the 0.12.17097 and the 0.15.18771 and with these versions the error would occure.
The OLI Question has nothing specific it is a very simple sample table.

@OlivierHellmann, as the issue seems to be fixed with the version 0.16.16948, may I close this issue?

@qutreson yeah i didn't have any similar issues after the update. You can close this issue. Thanks for all help

Was this page helpful?
0 / 5 - 0 ratings