Replies: 1 comment
-
@betsegaw No, BindingRedirects are all automatic these days. If those are needed, they need to be created at the entry-point of the application. The code you showed above works fine in PowerShell 7. Now, if you were on an old PowerShell 5.x - that's probably .NET Framework 4.6 or something. You'd need to add binding-redirects manually to PowerShell. Something like nuget install system.memory -outputdirectory .
$memory = [reflection.assembly]::LoadFrom((Resolve-Path .\System.Memory.4.5.4\lib\netstandard2.0\System.Memory.dll))
$redirect = [ResolveEventHandler] {
param($sender, $e)
if ($e.Name -like "System.Memory,*") { return $memory }
return $null
}
[appdomain]::CurrentDomain.add_AssemblyResolve($redirect) Should get you on the right track, note that this is probably not complete: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Information
Describe the bug
Loading nuget package in Powershell and trying to use it results in an exception with
Could not load file or assembly 'System.Memory...
To Reproduce
[System.Reflection.Assembly]::LoadFrom("/path/to/lib/netstandard2.0/Spectre.Console.dll")
[Spectre.Console.AnsiConsole]::Markup("[underline red]Hello[/] World!")
Expected behavior
Nicely formatted output
Actual output
Additional context
It seems that this is a lack of binding redirects that ensure that the nuget package can use the latest version rather than lock onto a specific version?
Also, might be resolved by including the following
Beta Was this translation helpful? Give feedback.
All reactions