unable to use PS scripts after updating to AZ modules 4.1.0
Closed this issue · 13 comments
Getting the following error when running PS scripts for Azure after upgrading to Az modules 4.1.0
installed older version 3.6.1 still get same error
repaired .net still get the error.
Failed to create a 'Settings' from the text 'Assembly references and imported namespaces serialized as XML namespaces'.
At C:\Scripts_ARM_DEPLOY_MD\CURRENT - DEPLOY-LB-MD-LAB.ps1:1 char:1
- ##################################################################### ...
-
+ CategoryInfo : OperationStopped: (:) [], XamlObjectWriterException + FullyQualifiedErrorId : System.Xaml.XamlObjectWriterException
-->
Description
Steps to reproduce
Environment data
Module versions
Debug output
Error output
@rlhip , could you share your script? If you meet the issue even you install 3.6.1, please ensure you remove installed Az 4.1 modules at the first and restart PowerShell because PowerShell always loads the latest version.
You can find installed module via below cmdlet and then go to folder to delete them. Please note that do not remove all because some of them are required by PowerShell and do not belong to Azure PowerShell
Get-Module -Name Az* -ListAvailable
You also can use Resolve-AzError
to get the list of errors during scripts execution. Please share to us.
hi here is the output.
PS C:\Scripts_ARM_DEPLOY_MD> Resolve-AzError
WARNING: Breaking changes in the cmdlet 'Resolve-AzError' :
WARNING: - The Resolve-Error
alias will be removed in a future release. Please change any scripts that use this alias to use Resolve-AzError
instead.
WARNING: NOTE : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.
HistoryId: -1
Message : Failed to create a 'Settings' from the text 'Assembly references and imported namespaces serialized as XML namespaces'.
StackTrace : at System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo) at System.Xaml.XamlObjectWriter.Logic_CreatePropertyValueFromValue(ObjectWriterContext ctx) at System.Xaml.XamlObjectWriter.WriteEndMember() at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter) at System.Xaml.XamlServices.Load(XamlReader xamlReader) at System.Activities.XamlIntegration.ActivityXamlServices.Load(XamlReader xamlReader, ActivityXamlServicesSettings settings) at System.Activities.XamlIntegration.ActivityXamlServices.Load(XmlReader xmlReader, ActivityXamlServicesSettings settings) at System.Activities.XamlIntegration.ActivityXamlServices.Load(TextReader textReader, ActivityXamlServicesSettings settings) at Microsoft.PowerShell.Commands.ImportWorkflowCommand.ConvertXamlToActivity(String xaml) at Microsoft.PowerShell.Workflow.DefinitionCache.CompileActivityAndSaveInCache(WorkflowJobDefinition definition, Activity activityTree, Dictionary
2 requiredAssemblies, Boolean& windowsWorkflow,
String rootWorkflowName)
at Microsoft.PowerShell.Commands.ImportWorkflowCommand.CreateFunctionFromXaml(String name, String xaml, Dictionary2 requiredAssemblies, String[] dependentWorkflows, String dependentAssemblyPath, Dictionary
2 parameterValidation, String modulePath, Boolean scriptWorkflow, String workflowAttributes, String scriptContent, String fullScript, String rootWorkflowName,
Nullable1 sourceLanguageMode, ReadOnlyCollection
1 attributeAstCollection)
at Microsoft.PowerShell.Workflow.AstToWorkflowConverter.CompileSingleWorkflow(Scope scope, FunctionDefinitionAst func, Dictionary2 scriptBlockTokenCache, PSModuleInfo definingModule, IEnumerable
1 assemblyList, Dictionary2 activityMap, HashSet
1 processedActivityLibraries, PowerShell invoker, Nullable1 sourceLanguageMode, String rootWorkflowName) at Microsoft.PowerShell.Workflow.AstToWorkflowConverter.CompileWorkflowsImpl(ScriptBlockAst ast, PSModuleInfo definingModule, InitialSessionState initialSessionState, Nullable
1
sourceLanguageMode, ParseException& parsingErrors, String rootWorkflowName)
at Microsoft.PowerShell.Workflow.AstToWorkflowConverter.CompileWorkflows(ScriptBlockAst ast, PSModuleInfo definingModule, InitialSessionState initialSessionState, Nullable`1 sourceLanguageMode,
ParseException& parsingErrors)
at System.Management.Automation.FunctionOps.DefineWorkflows(ExecutionContext context, ScriptBlockAst scriptBlockAst)
Exception : System.Xaml.XamlObjectWriterException
InvocationInfo : {}
Line : ###################################################################################################
Position : At C:\Scripts_ARM_DEPLOY_MD\CURRENT - DEPLOY-LB-MD-LAB.ps1:1 char:1
+ ##################################################################### ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : -1
Message : Could not load file or assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
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.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean
mustBeInheritable)
at System.Reflection.CustomAttribute.IsDefined(RuntimeAssembly assembly, RuntimeType caType)
at Microsoft.VisualBasic.Activities.XamlIntegration.VisualBasicExpressionConverter.AssemblyCache.EnsureInitialized()
at Microsoft.VisualBasic.Activities.XamlIntegration.VisualBasicExpressionConverter.WrapCachedMapping(NamespaceDeclaration prefix, ReadOnlyXmlnsMapping& readOnlyMapping)
at Microsoft.VisualBasic.Activities.XamlIntegration.VisualBasicExpressionConverter.CollectXmlNamespacesAndAssemblies(ITypeDescriptorContext context)
at Microsoft.VisualBasic.Activities.XamlIntegration.VisualBasicSettingsConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateObjectWithTypeConverter(ServiceProviderContext serviceContext, XamlValueConverter1 ts, Object value) at System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter
1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo)
Exception : System.IO.FileNotFoundException
InvocationInfo : {}
Line : ###################################################################################################
Position : At C:\Scripts_ARM_DEPLOY_MD\CURRENT - DEPLOY-LB-MD-LAB.ps1:1 char:1
+ ##################################################################### ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : -1
HistoryId: 3
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\1.8.0\Az.Accounts.psm1:68 char:17
+ ... Add-Type -Path $_.FullName -ErrorAction Ignore | Out-N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
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\1.8.0\Az.Accounts.psm1:68 char:17
+ ... Add-Type -Path $_.FullName -ErrorAction Ignore | Out-N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
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\1.8.0\Az.Accounts.psm1:68 char:17
+ ... Add-Type -Path $_.FullName -ErrorAction Ignore | Out-N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
HistoryId: -1
Message : Unable to find type [Microsoft.PowerShell.Commands.PowerShellGet.Telemetry].
StackTrace : at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception : System.Management.Automation.RuntimeException
InvocationInfo : {}
Line : $telemetryMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | Get-Member -Static).Name
Position : At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:715 char:26
+ ... yMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : -1
The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
PS C:\Scripts_ARM_DEPLOY_MD>
@rlhip , could you please share the following info with us:
- Please run $PSVersionTable and paste the output in the below code block
- Please run (Get-Module -ListAvailable) and paste the output in the below code block
- Set $DebugPreference='Continue' before running your script and paste the result in the below code block
- It would be much helpful if you could share us your script
@rlhip , sorry for late response, could you please share minimal script that could reproduce the error?
@rlhip, the issue seems to be related to PowerShell WorkFlow, I could not transfer the issue to powershell repo since it belongs to different org. Please submit one issue at https://github.com/PowerShell/PowerShell/issues
@rlhip, we found that the issue could be worked around by defining workflow in the very beginning of your script, i.e. before importing Az.Accounts module. Meanwhile we'll fix this issue in next Az release (6/23), thank you for your patience.
Yes, you just need to remove workflow section, please let us know if any other issue.
Close the issue as it is resolved in Az 4.3. Please create new issue if any concern, thanks.