-
Notifications
You must be signed in to change notification settings - Fork 22
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
Assembly with same name is already loaded #1083
Comments
Even specifying |
Also encountering similar stuff but with Get-MgUser |
I suspect this may be a MS Graph SDK issue and not necessarily an Entra PowerShell module issue. Whatever the cause, there are several closed issues in the Graph SDK PowerShell repo that point to purging the module[s] as a solution.
These aren't as valuable as a real root cause analysis that finds and fixes the actual problem, but I'm curious if it may help address the symptoms described in this issue. |
Thanks Sam. I was able to resolve my issue loading Microsoft.Graph.Users by upgrading the module. |
This is a common issue with PowerShell modules that uses different versions of the same assembly. If you do not address this when designing the module, it will not be usable with other modules, unless you are very careful loading one module before the other to get the newest assembly loaded (often Authentication is the culprit). The solution is called Assembly Load Contexts Bridging (ALC). 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. Since this module is still very young, this would be the perfect time to adapt ALC Bridging pattern to the code! |
Thanks for the tip! Is there any functional equivalent that is backwards compatible with Windows PowerShell 5.1? |
Related issue/solution: #1242 |
While I've worked with Entra PowerShell, Visual Studio code has crashed.
After starting a new session, Entra PowerShell command couldn't run. It failed with the "Assembly with same name is already loaded" error. Entra PowerShell command was the first executed in that new session and Get-Module executed after didn't show any Microsoft.Graph module loaded.
Even after the restart of the VM, I couldn't run Entra PowerShell commands.
Explicitly loading the module with
Import-Module Microsoft.Graph.Entra
doesn't provide any additional details about the problem.The text was updated successfully, but these errors were encountered: