Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powershell Assembly Load Contexts Sample Code Doesn't Compile #8481

Closed
3 tasks done
microalps opened this issue Jan 13, 2022 · 1 comment · Fixed by #8539
Closed
3 tasks done

Powershell Assembly Load Contexts Sample Code Doesn't Compile #8481

microalps opened this issue Jan 13, 2022 · 1 comment · Fixed by #8539
Labels
area-sdk-docs Area - SDK docs issue-doc-bug Issue - error in documentation

Comments

@microalps
Copy link

Prerequisites

  • Write a descriptive title.
  • Search the existing issues.
  • I am reporting the documentation problem for version of PowerShell I am using.

Version

7.2

Link to affected document

https://docs.microsoft.com/en-us/powershell/scripting/dev-cross-plat/resolving-dependency-conflicts?view=powershell-7.2

Description of the documentation error

  1. AlcModuleAssemblyLoadContext does not handle if the file to load is not in the path. In this case it should return null and not LoadFromAssemblyPath. In my test, this was triggering an error about System.Runtime not being found.
  2. AlcModuleResolveEventHandler OnRemove signature is incorrect and is missing the PSModuleInfo argument. See https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.imoduleassemblycleanup.onremove?view=powershellsdk-7.0.0#System_Management_Automation_IModuleAssemblyCleanup_OnRemove_System_Management_Automation_PSModuleInfo_

Suggested fix

Add the following for #1

            if (!File.Exists(assemblyPath))
                return null;

Change the line with OnRemove to:

public void OnRemove(PSModuleInfo psModuleInfo)
@microalps microalps added issue-doc-bug Issue - error in documentation needs-triage Waiting - Needs triage labels Jan 13, 2022
@sdwheeler sdwheeler added review-shiproom Waiting - for Shiproom discussion area-sdk-docs Area - SDK docs and removed needs-triage Waiting - Needs triage labels Jan 18, 2022
@daxian-dbw
Copy link
Contributor

Thanks @microalps! PR to fix this is out: #8539

@sdwheeler sdwheeler removed the review-shiproom Waiting - for Shiproom discussion label Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-sdk-docs Area - SDK docs issue-doc-bug Issue - error in documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants