Still getting assembly conflict issues when using Start-ThreadJob #3139
Replies: 1 comment
-
The issue with colliding assemblies should now be fixed! |
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
Uh oh!
There was an error while loading. Please reload this page.
-
@erwinvanhunen using your example from the demo at ECS, using Start-ThreadJob to avoid assembly conflicts, I'm still getting assembly conflicts:
Using PoSh 7.3.4
Repro:
Also a check for loaded modules show that modules are indeed not loaded, but checking the appdomain for assemblies reveal that pnp powershell are indeed loaded witch will cause trouble later:
Now if we try to run an Az command like Get-AzADUser in a seperate job look what happens:
The 'Get-AzADUser' command was found in the module 'Az.Resources', but the module could not be loaded due to the following error: [Assembly with same name is already loaded]
For more information, run 'Import-Module Az.Resources'.
Running the exact same code in a new PowerShell session works fine, but even though running as seperate jobs, as the assemblies are loaded into Assembly Load Context on AppDomain level, we still see assembly conflict even when running the code in seperate jobs.
Checking loaded identity assemblies also shows that slightly different versions are loaded depending on order of running the jobs.
I know you did a lot to prevent these issues when upgrading to 2.1.1 but did you consider ALC bridging?
ALC is the "new" way of loading assemblies in PowerShell 7, and should have better ways of handling multiple versions of the same assembly. There are a few samples in the code below that show how to avoid this breaking code into two modules and using the IModuleAssemblyInitializer to lazy load and undload assemblies into ALC.
https://learn.microsoft.com/en-us/powershell/scripting/dev-cross-plat/resolving-dependency-conflicts?view=powershell-7.3#more-robust-solutions
Would love to hear your thoughts? :)
Beta Was this translation helpful? Give feedback.
All reactions