Azure / Azure/azure-powershell

Connect-AzAccount : Method 'get_SerializationSettings' in type

Open
#22,903 8 comments 1 reaction 0 assignees View on GitHub
customer-reported needs-team-attention question
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

Hello,
I'm on a windows 2026 server.
I installed the az.storage 5.10.0 module (which installs the az.accounts module 2.13.1).
The command "connect-azaccount" fails with the error "Method 'get_SerializationSettings' in type..".
Articles say that I should use the older version of az.accounts 2.12.1. I uninstalled the 2.13.1? install the 2.12.1. It's OK :-).
But later in my script I need the command "get-AZStorageaccount..". It's not OK:
import-module az.storage gives the error
"C:\Program Files\WindowsPowerShell\Modules\Az.Storage\5.10.1\Az.Storage.psm1 : This module requires Az.Accounts
version 2.13.1. An earlier version of Az.Accounts is imported in the current PowerShell session"

OK, I tried to
remove-module az.accounts -Force
Install-Module -Name Az.Accounts # it's ok, installing the 2.13.1 module sid by side with 2.12.1
import-module az.storage
-->
Import-Module : Could not load type
'Microsoft.WindowsAzure.Commands.Common.CustomAttributes.GenericBreakingChangeWithVersionAttribute' from assembly
'Microsoft.Azure.PowerShell.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
At C:\Program Files\WindowsPowerShell\Modules\az.storage\5.10.1\Az.Storage.psm1:99 char:1
+ Import-Module (Join-Path -Path $PSScriptRoot -ChildPath Microsoft.Azu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], TypeLoadException
+ FullyQualifiedErrorId : System.TypeLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand

On an other wn2016 server, with the same .Net framework version installed (the highest possible one is 4.8 on this OS), and the same powershell modules az.storage 5.10.0 module (which installs the az.accounts module 2.13.1), all my commands are OK.

I do not understand.
Any other idea ?
Thank you.

### Script or Debug output

_No response_

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 5.1.14393.5582
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.5582
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

### Module versions

```PowerShell
Script 2.13.1 Az.Accounts
Script 5.10.1 Az.Storage
```

### Error output

```PowerShell
Message : Could not load type
'Microsoft.WindowsAzure.Commands.Common.CustomAttributes.GenericBreakingChangeWithVersionAttribute'
from assembly 'Microsoft.Azure.PowerShell.Common, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
StackTrace : at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs,
Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken,
RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments,
Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord,
MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken
decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes,
IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean&
ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32
decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable,
IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType,
Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[T](MemberInfo element, Boolean
inherit)
at System.Management.Automation.Runspaces.PSSnapInHelpers.GetCustomAttribute[T](TypeInfo
decoratedType)
at
System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzeModuleAssemblyWithReflection(Assembly
assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, Boolean isModuleLoad,
Dictionary`2& cmdlets, Dictionary`2& aliases, Dictionary`2& providers, String helpFile, Type&
randomCmdletToCheckLinkDemand, Type& randomProviderToCheckLinkDemand)
at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzePSSnapInAssembly(Assembly
assembly, String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, Boolean isModuleLoad,
Dictionary`2& cmdlets, Dictionary`2& aliases, Dictionary`2& providers, String& helpFile)
at System.Management.Automation.Runspaces.InitialSessionState.ImportCmdletsFromAssembly(Assembly
assembly, PSModuleInfo module)
at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule,
Boolean trySnapInName, 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.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions
importModuleOptions, String name)
at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
Exception : System.TypeLoadException
InvocationInfo : {Import-Module}
Line : Import-Module (Join-Path -Path $PSScriptRoot -ChildPath
Microsoft.Azure.PowerShell.Cmdlets.Storage.dll)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with Connect-AzAccount and Import-Module Az.Storage using the listed Az.Accounts and Az.Storage versions. Start at Az.Storage.psm1 line 99 and inspect the referenced Microsoft.Azure.PowerShell.Common assembly; done means both modules import successfully on the reported Windows PowerShell environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.