cloudbase / powershell-yaml

PowerShell CmdLets for YAML format manipulation
Apache License 2.0
434 stars 78 forks source link

Cannot find type [YamlDotNet.Core.Parser] #122

Closed stottler closed 3 months ago

stottler commented 8 months ago

Hello,

The module was working yesterday when I left my office. I changed nothing and am now getting this error.

New-Object: Cannot find type [YamlDotNet.Core.Parser]: verify that the assembly containing this type is loaded. New-Object: Cannot find type [YamlDotNet.RepresentationModel.YamlStream]: verify that the assembly containing this type is loaded. InvalidOperation: Unable to find type [YamlDotNet.Core.IParser].

Example code where it's breaking. $yamlfile = Get-Content -Path "config.yaml" $yaml = ConvertFrom-Yaml $yamlfile

I'm not sure what broke.

gabriel-samfira commented 3 months ago

This can only happen if you already had another YamlDotNet assembly loaded in your current session that didn't have those types in it. Perhaps another powershell module that loads an older version of YamlDotNet?

If this is still happening in your env and you are running powershell version 6.0+, try the following version:

Install-Module -Name powershell-yaml -AllowPrerelease -Version 0.4.8-rc1 -Force

This pre-release loads the YamlDotNet bundled with powershell-yaml in another assembly load context and uses that version.

gabriel-samfira commented 3 months ago

Closing this. Feel free to re-open if the issue persists.