PSReadLine icon indicating copy to clipboard operation
PSReadLine copied to clipboard

dotnet type lookup breaks after importing SharePointServer PowerShell module

Open JMyklebust opened this issue 1 year ago • 6 comments

Prerequisites

  • [x] Write a descriptive title.
  • [x] Make sure you are able to repro it on the latest released version
  • [x] Search the existing issues, especially the pinned issues.

Exception report

N/A

Screenshot

N/A

Environment data

PS Version: 5.1.20348.2849
PS HostName: ConsoleHost
PSReadLine Version: 2.4.1-beta1
PSReadLine EditMode: Windows
OS: 10.0.20348.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 9001

Steps to reproduce

Try to autocomplete a dotnet type after importing the SharePointServer PowerShell module. Applies both to tab completion and selection using Ctrl + Space.

  1. Start a new PowerShell session
  2. Test type autocomplete by for example typing [date and then pressing Ctrl + Space
  3. Auto complete suggestions come up.
  4. Import module with Import-Module SharePointServer
  5. Test autocomplete with [date and then pressing Ctrl + Space

Expected behavior

Autocomplete should work both before and after importing the SharePointServer module.

Actual behavior

After the module import, autocomplete is broken for dotnet objects. More specifically the function to complete types names is broken. Autocomplete for Cmdlets and methods of types is working, but type name is not.

  • Typing Get-Mo and pressing Ctrl + Space gives options to complete.
  • Typing [datetime] and pressing Ctrl + Space gives method suggestions.
  • Typing [date and pressing Ctrl + Space (or pressing just Tab) gives no results.

Additonal info: While PSReadline itself does not seem to generate a visible exception, there is some exceptions generated in VSCode with the PowerShell extension, so I'm adding it here if possibly relevant. But the reproduction steps has been run directly in PowerShell outside of VSCode.

2025-03-25 15:01:05.940 [info] [PSES] [Error - 3:01:05 PM] <Error>Microsoft.PowerShell.EditorServices.Handlers.PsesCompletionHandler: Error Occurred in TabExpansion2 | 
2025-03-25 15:01:05.945 [info] [PSES] [Warn  - 3:01:05 PM] <Warning>Microsoft.PowerShell.EditorServices.Handlers.PsesCompletionHandler: Exception occurred while running handling completion request - System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.PowerShell.EditorServices.Handlers.PsesCompletionHandler.<GetCompletionsInFileAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Handlers.PsesCompletionHandler.<Handle>d__13.MoveNext() | 
````

JMyklebust avatar Mar 25 '25 14:03 JMyklebust

Which version & edition of SharePoint Server - please include information about what patches have been applied to the environment too

kilasuit avatar May 09 '25 03:05 kilasuit

This is on Sharepoint Server Subscription Edition currently running cumulative patch of April 2025 (KB5002705). It's running as a single server system, and it's installed on Windows Server 2022 also running with the April 2025 Windows patches.

This environment has a test and prod server that have matching configurations for the most part, so the issue is existing 2 two different machines.

JMyklebust avatar May 09 '25 08:05 JMyklebust

@JMyklebust Can you run TabExpansion2 -inputScript '[date' -cursorColumn 5 after importing SharePointServer module and share the results?

daxian-dbw avatar May 09 '25 17:05 daxian-dbw

This is the result.

PS> TabExpansion2 -inputScript '[date' -cursorColumn 5

Exception calling "CompleteInput" with "3" argument(s): "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."
At line:38 char:16
+ ...      return [System.Management.Automation.CommandCompletion]::Complet ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ReflectionTypeLoadException

Side note; I'm away from work for 2 weeks now so can't really reply in a prompt manner in that time. Technically I'm already off work but figured I could test this now while I had a chance.

JMyklebust avatar May 09 '25 18:05 JMyklebust

Thanks @JMyklebust! When you get a chance, can you please run it again and share the information exposed by the LoaderExceptions property?

daxian-dbw avatar May 09 '25 18:05 daxian-dbw

Now I'm back and can give feedback. This is the content of LoaderExceptions:

PS> $er.Exception.InnerException.LoaderExceptions

Could not load file or assembly 'Microsoft.Bond.Interfaces, Version=3.0.3.0, Culture=neutral, PublicKeyToken=cf7230938fec607f' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Bond.Interfaces, Version=3.0.3.0, Culture=neutral, PublicKeyToken=cf7230938fec607f' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Bond.Interfaces, Version=3.0.3.0, Culture=neutral, PublicKeyToken=cf7230938fec607f' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Bond.Interfaces, Version=3.0.3.0, Culture=neutral, PublicKeyToken=cf7230938fec607f' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Bond.Interfaces, Version=3.0.3.0, Culture=neutral, PublicKeyToken=cf7230938fec607f' or one of its dependencies. The system cannot find the file specified.

JMyklebust avatar May 27 '25 08:05 JMyklebust