-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
AccountsIssues in Az.Accounts except authentication relatedIssues in Az.Accounts except authentication relatedbugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reported
Description
Description
Importing Az.Accounts with a version above 2.7.0 will silently add an error to $error when using PowerShell 5.1.x
The latest version (2.7.5) will show the the following:
Could not load file or assembly 'System.Reflection.DispatchProxy, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f 5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I've tried this on multiple workstations with the same effect. The module itself does seem to work normally.
Using Powershell 7.x does not give an error.
Issue script & Debug output
PS C:\WINDOWS\system32> import-module az.accounts
PS C:\WINDOWS\system32> $error
Add-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more informati
on.
At C:\Program Files\WindowsPowerShell\Modules\az.accounts\2.7.5\Az.Accounts.psm1:39 char:21
+ ... Add-Type -Path $_.FullName -ErrorAction Ignore | Out-N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException
+ FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeComma
nd
PS C:\WINDOWS\system32> $error[0].Exception.GetBaseException().LoaderExceptions
Could not load file or assembly 'System.Reflection.DispatchProxy, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f
5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.Environment data
Name Value
---- -----
PSVersion 5.1.22000.613
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22000.613
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1Module versions
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.7.5 Az.ACcounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Conn...Error output
Message : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
StackTrace : at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
at System.Management.Automation.CommandProcessorBase.Complete()
Exception : System.Reflection.ReflectionTypeLoadException
InvocationInfo : {Add-Type}
Line : Add-Type -Path $_.FullName -ErrorAction Ignore | Out-Null
Position : At C:\Program Files\WindowsPowerShell\Modules\az.accounts\2.7.5\Az.Accounts.psm1:39 char:21
+ ... Add-Type -Path $_.FullName -ErrorAction Ignore | Out-N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 29
The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.Metadata
Metadata
Assignees
Labels
AccountsIssues in Az.Accounts except authentication relatedIssues in Az.Accounts except authentication relatedbugThis issue requires a change to an existing behavior in the product in order to be resolved.This issue requires a change to an existing behavior in the product in order to be resolved.customer-reported