PowerShell / PowerShell/vscode-powershell

Unable to load Az modules - Assembly with same name is already loaded

Aperta
#4,727 33 commenti 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area-Extension Terminal Issue-Bug
Lingua principale
TypeScript
Stelle
1.9k
Fork
548
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Prerequisites
  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
Summary

If you load a PowerShell file that has references to Azure PowerShell commands the assemblies are being loaded without loading the module fully.

This is repeat of #3012 which was closed with no solution. Extensions do not matter in this case, it is when a file that has Azure module references is opened the assemblies get loaded but not the actual modules.

PowerShell Version
> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.13
PSEdition                      Core
GitCommitId                    7.2.13
OS                             Darwin 21.6.0 Darwin Kernel Version 21.6.0: Thu Jul  6 22:20:00 PDT 2023; root:xnu-8020.240.18.702.13~1/RELEASE_A…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visual Studio Code Version
> code-insiders --version 
1.82.0-insider
f1302be1e67e3af5fbeb8bbb2ea784de7bc96150
arm64
Extension Version
> code --list-extensions --show-versions | Select-String powershell

ms-vscode.powershell@2023.6.0
Steps to Reproduce
  1. Close all PowerShell files
  2. Restart session for PowerShell Extension
  3. Run following command to list loaded assemblies
[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location, GlobalAssemblyCache, IsFullyTrusted | Where FullName -like '*azure*' | ft
  1. Note nothing is returned
  2. Run Get-Module Az*
  3. Nothing is returned
  4. Open file (any file) with Az PowerShell references
  5. Rerun step 3
  6. All assemblies for the Az.Accounts and related commands are loaded
  7. Rerun step 5
  8. Nothing is returned
  9. Run Import-Module Az.Accounts
  10. Error returned: Import-Module: Assembly with same name is already loaded
Visuals

https://github.com/PowerShell/vscode-powershell/assets/11204251/113bb121-5cd8-482d-847b-184bb594cb84

Logs

ext_logs.zip

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo la sequenza nell’estensione PowerShell: apri un file con riferimenti ad Az, ispeziona gli assembly caricati con il comando AppDomain fornito, quindi esegui Get-Module Az* e Import-Module Az.Accounts. Usa i log allegati dell’estensione e il percorso di caricamento degli assembly dell’estensione per determinare perché gli assembly vengono caricati senza il modulo; il lavoro è completato quando Az.Accounts viene importato correttamente dopo l’apertura del file.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell, typescript, vscode
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.