mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
When an assembly that exists outside of the trusted platform assembly list but in the GAC on Windows was loaded, the use of `Assembly.Load` before the `LoadFromAssemblyPath` caused a recursive loop to occur. This happens because an `Assembly.Load` on a not-yet-loaded assembly is overridden, thus calling back into the `AssemblyLoadContext.Load` override. By attempting to load from the file path first, we avoid this loop. However, loading TPA assemblies by their path throws an exception, so now we catch this particular exception and attempt the load through `Assembly.Load`. This is safe for TPA assemblies since they're already loaded, thus the `Assembly.Load` does not re-load the assembly, but simply returns it.