PowerShell / SecretManagement

PowerShell module to consistent usage of secrets through different extension vaults
MIT License
317 stars 46 forks source link

Test-SecretVault cmdlet failing with "Assembly with same name is already loaded" #198

Closed MVogwell closed 1 year ago

MVogwell commented 1 year ago

Prerequisites

Steps to reproduce

Running Test-SecretStore cmdlet in PowerShell 7.2.5 (and 7.2.4) from module microsoft.powershell.secretmanagement version 1.1.2 (and 1.1.1) is intermittently failing with the error "Assembly with same name is already loaded".

Expected behavior

should return boolean value indicating whether the named SecretVault is available

Actual behavior

Returning error "Assembly with same name is already loaded"

Error details

ErrorRecord                 : Assembly with same name is already loaded
WasThrownFromThrowStatement : False
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]
                              Invoke(System.Collections.IEnumerable)
Message                     : Assembly with same name is already loaded
Data                        : {}
InnerException              : System.IO.FileLoadException: Assembly with same name is already loaded
                                 at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo
                              parentModule, String moduleName, String fileName, Assembly assemblyToLoad, String
                              moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags
                              manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean&
                              found, String shortModuleName, Boolean disableFormatUpdates)
                                 at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo
                              parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object
                              privateData, ImportModuleOptions& options, ManifestProcessingFlags
                              manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
                                 at
                              Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(PSModuleInfo
                              parentModule, ModuleSpecification moduleSpecification, String moduleBase, Boolean
                              searchModulePath, String prefix, SessionState ss, ImportModuleOptions options,
                              ManifestProcessingFlags manifestProcessingFlags, Boolean loadTypes, Boolean loadFormats,
                              Object privateData, Boolean& found, String shortModuleName, Nullable`1
                              manifestLanguageMode)
                                 at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String
                              moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable
                              localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion,
                              Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid,
                              ImportModuleOptions& options, Boolean& containedErrors)
                                 at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo
                              parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object
                              privateData, ImportModuleOptions& options, ManifestProcessingFlags
                              manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
                                 at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(Impor
                              tModuleOptions importModuleOptions, String name)
                                 at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithT
                              elemetry(ImportModuleOptions importModuleOptions, String name)
                                 at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
                                 at System.Management.Automation.CommandProcessor.ProcessRecord()
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233087
StackTrace                  :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                 at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace
                              rs, Boolean performSyncInvoke)
                                 at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataColl
                              ection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
                                 at
                              System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1
                              input, PSDataCollection`1 output, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input,
                              PSDataCollection`1 output, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList`1
                              output, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.Invoke[T]()
                                 at System.Management.Automation.CommandDiscovery.AutoloadSpecifiedModule(String
                              moduleName, ExecutionContext context, SessionStateEntryVisibility visibility, Exception&
                              exception)

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

1.1.2

Visuals

image

MVogwell commented 1 year ago

Test-SecretVault_Exception.txt

MVogwell commented 1 year ago

Found the error was further down in loading the module rather than running the Test-SecretVault cmdlet. Even running "import-module Microsoft.PowerShell.SecretManagement -force" causes the error to be thrown. I will close this however because it's not directly related to Test-SecretVault by the looks of it.