Skip to content

Conversation

@adityapatwardhan
Copy link
Member

PR Summary

When a binary module has the module assembly in GAC, we load the assembly from GAC before trying to load it from module base path.

This change attempts to load it from module base path before looking up in GAC.

PR Checklist

@adityapatwardhan
Copy link
Member Author

@SteveL-MSFT I guess this would technically be a breaking change if someone had a assembly with the same name in the module base folder and are relying on loading it from GAC instead. But, I believe that should be a very rare occurance. Your thoughts?

@SteveL-MSFT
Copy link
Member

@adityapatwardhan I can't imagine a scenario where a module author has an assembly in their module base folder but expects the assembly from the GAC to be loaded

@TravisEz13 TravisEz13 added the Breaking-Change breaking change that may affect users label Oct 19, 2018
@TravisEz13
Copy link
Member

Technically it's breaking, let's document it as breaking, but I don't think this needs committee review

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we already got the resolved assembly path, we can skip the loading, right? The loading is solely for getting the path of the assembly. When the target assembly is in GAC, we have to load it in order to get the path, but not if we already resolved the assembly file path.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, we actually want to load from module base first. In the Resolve method, we do not have access to module base so we need to do this here. If there are alternatives, please suggest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to the code so it is clear to other developers that we really want to load the assembly here, not just return the pathname. Thanks!

Copy link
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to the code so it is clear to other developers that we really want to load the assembly here, not just return the pathname. Thanks!

@adityapatwardhan
Copy link
Member Author

@daxian-dbw Please have another look.

@anmenaga
Copy link

@SteveL-MSFT @adityapatwardhan Here is example scenario: servicing a multi-version module.
Let's say there is a widely-used module that over time released several versions.
Then someone discovers a security bug in .NET that requires a client-side code fix from module authors.
It's a lot easier to put a fixed DLL into GAC than try to update DLL in all module version folders.

@adityapatwardhan is there an issue for this PR? did somebody complain?

@SteveL-MSFT
Copy link
Member

@anmenaga the real world scenario is that we have Windows partners that also ship their modules on PSGallery. The PSGallery version that the user explicitly installed may be newer than the one that is inbox. Currently, importing the module loads the older assembly in the GAC which doesn't match the updated module.

@anmenaga
Copy link

@SteveL-MSFT That's a valid scenario.
Though ideally, I think, the load order should be configurable. Is it something that can be placed in a config file?

@SteveL-MSFT
Copy link
Member

@anmenaga The updated one in the GAC may not be compatible with modules that were tested against a specific version. I think this is the tradeoff of app-local versions of assemblies. At this time, I don't think we should solve this problem universally.

@adityapatwardhan
Copy link
Member Author

@TravisEz13 Assigning this to you as I would like to get this in the next release.

@TravisEz13 TravisEz13 merged commit b5ab2dd into PowerShell:master Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants