You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Assembly Conflicts with Microsoft.Graph Module #3637
Running Microsoft.Graph cmdlets, such as Connect-MgGraph and Get-MgApplication, produce an assembly conflict error if run after PnP.PowerShell assemblies have already been loaded.
Expected behavior
According to release notes for PnP.PowerShell 2.3.0, assembly conflicts have been resolved. With this being true, I was hopeful I could develop a script that used cmdlets from both PnP.PowerShell and Microsoft.Graph. In my scenario, this doesn't appear to be the case.
Actual behavior
Results from trying to run Connect-MgGraph and Get-MgApplication after PnP had already been loaded:
Output of assemblies loaded in the session. The two assemblies called out in the MgGraph exception are sourced from the PnP.PowerShell Module
I fixed this by grabbing the Microsoft.Graph.Core.dll from Microsoft.Graph.Authentication and dropping it right into C:\Program Files\PowerShell\Modules\PnP.PowerShell\2.3.8\Core
Not the best, nor the most elegant solution, but it worked.
I fixed this by grabbing the Microsoft.Graph.Core.dll from Microsoft.Graph.Authentication and dropping it right into C:\Program Files\PowerShell\Modules\PnP.PowerShell\2.3.8\Core
Not the best, nor the most elegant solution, but it worked.
Also grab the Microsoft.Identity.Client.dll from Microsoft.Graph.Authentication and replace the PnP version. This resolved Connect-MGGRAPH error trying to use the older dll files from the PnP module if it was called first.
Thanks for the suggested workarounds - I'll be sure to test those. I am concerned about the lengthy regression testing that might be required by replacing these, as I'm not sure if the replaced DLLs will cause issues with the rest of my code.
As an update to my previous post, I have tried the DLL replacements as indicated above. While this resolves the authentication issue, calling other Graph cmdlets (such as Get-MgUser) reveals other assembly conflicts
Get-MgUser_List: Method not found: 'Void Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[], Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.
Unfortunately, we are at a crossroads in getting utility out of both PnP.PowerShell and Microsoft.Graph.
I was just able to pull Users and Applications from Graph API without any assembly conflicts. I did not know this cmdlet exists, but it seems like an excellent workaround. A quick sample of a couple commands I ran
The issue persists with the new version of graph (2.12.0) and PNP 2.3.0, could you please fix this issue? otherwise people are forced to work with the old PNP version 1.12.0.
Error Message when connecting to graph, after connecting to PNP:
ERROR - Connect to Microsoft Graph failed.(TenantId: tttech365.onmicrosoft.com, AppId ****)
ERROR -
Connect-MgGraph:
Line |
135 | Connect-MgGraph -TenantId $AzureTenant -ClientId $AppId - …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ClientCertificateCredential authentication failed: Could not load type 'Microsoft.Identity.Client.BaseAbstractApplicationBuilder`1' from assembly 'Microsoft.Identity.Client, Version=4.50.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'.
Reacted by Emma Degerman, jgriff500, nicole-ge, scm7ak and devops-fan
Same issue here. Absolutely horrible bug tbh.
This is currently a hard blocker for us as for security and regularoty reasons we may not tamper with module files of modules, hence we can't work with the workarround by @JNichNP
Reacted by jgriff500, nicole-ge, Fabian Franz Steiner and Mike Campbell
Add me to the list of people who are experiencing this issue. Brand new server with the lastest versions of PNP and Graph modules. There's gotta be a way to fix this. Seems both Graph and PNP teams are blaming the other team rather than coming up with a solution.
Reacted by Alexander Thurau, Mike Campbell and Darren Woodford
Our automation scripts are also failing with the same error and for the same reason. Another short-term (not ideal) workaround for using PnP 2.3 is to uninstall the MS Graph module and/or install Microsoft.Graph 2.8.
This DLL version conflict needs to be resolved in way that it doesn't keep happening every few updates.
Found this to be an awesome solution as it occurs for me in VsCode and the issue is that the PS extension is loading the modules and resulting in the wrong assemblies being loaded.
Essentially you set VSCode to run the file in a new terminal, rather than use the one the extension lives in.
I changed my launch to contain this. The createTemporaryIntegratedConsole being the key entry.
Hello all, thank you for the patience. Took quite a while , but we finally removed the Graph dependency which was causing the conflict. Would encourage you to update to the latest nightly builds (3.1.36-nightly or later ) and let us know.
Reacted by mark3grahams, Matthias Haldimann, Olav Rønnestad Birkeland and enthusol
I fixed this by grabbing the Microsoft.Graph.Core.dll from Microsoft.Graph.Authentication and dropping it right into C:\Program Files\PowerShell\Modules\PnP.PowerShell\2.3.8\Core
Not the best, nor the most elegant solution, but it worked.
With the nightly builds having a working fix for about 5 months now, what's the timeline looking like for a fixed version making it into a release?
I see workaround about connect-mggraph before the PNP connection, but my uses are more often interactive at a Powershell prompt, so depending on the day's tasks, I might connect in one order vs another, and may have a number of variables stuffed with data I'm working on - leaving those behind to start a new session is a pain.
@zaaj - sorry about the delay. We are currently blocked from a release due to certificate issues. We hope to have it out soon, preferably sometime this month itself .
I am also still having this issue in 3.1.0 Error "Get-MgUserMailFolder_List: Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'"
Work around is to run Connect-MgGraph and then run a command. This will ensure you are using the right dll. Then you can run Connect-PnPOnline and use both libraries with no issue.
@gautamdsheth Sorry for the direct ping but is there any timeline for a new release of PnP.PowerShell that includes this fix? Appreciate your work on it.
We just released a new version today after more than a year with this bug fix.
Sorry and apologies for the delay and thanks for the patience , will close this issue now !
Please do let us know if the issue persists with the 3.2.0 , from what i read, it was fixed in the nightly builds and the code related to this is present.
Reacted by Olav Rønnestad Birkeland, Bart Scholtus and Jørgen Darre
Reacted by Bart Scholtus, Chris H, enthusol, mark3grahams, Michael Mican and Dominik Stieberger
Activity
JNichNP commentedon Dec 20, 2023
I fixed this by grabbing the Microsoft.Graph.Core.dll from Microsoft.Graph.Authentication and dropping it right into C:\Program Files\PowerShell\Modules\PnP.PowerShell\2.3.8\Core
Not the best, nor the most elegant solution, but it worked.
Jaffa666 commentedon Dec 21, 2023
Also grab the Microsoft.Identity.Client.dll from Microsoft.Graph.Authentication and replace the PnP version. This resolved Connect-MGGRAPH error trying to use the older dll files from the PnP module if it was called first.
cprovpo commentedon Dec 26, 2023
Thanks for the suggested workarounds - I'll be sure to test those. I am concerned about the lengthy regression testing that might be required by replacing these, as I'm not sure if the replaced DLLs will cause issues with the rest of my code.
cprovpo commentedon Jan 12, 2024
As an update to my previous post, I have tried the DLL replacements as indicated above. While this resolves the authentication issue, calling other Graph cmdlets (such as Get-MgUser) reveals other assembly conflicts
Get-MgUser_List: Method not found: 'Void Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider..ctor(Azure.Core.TokenCredential, System.String[], Microsoft.Kiota.Authentication.Azure.ObservabilityOptions, System.String[])'.Unfortunately, we are at a crossroads in getting utility out of both PnP.PowerShell and Microsoft.Graph.
cprovpo commentedon Jan 12, 2024
One final update - I think I may have found a valuable workaround tool, and it's built in:
Invoke-PnPGraphMethod
I was just able to pull Users and Applications from Graph API without any assembly conflicts. I did not know this cmdlet exists, but it seems like an excellent workaround. A quick sample of a couple commands I ran
Hopefully this helps someone else!
fasteiner commentedon Jan 18, 2024
The issue persists with the new version of graph (2.12.0) and PNP 2.3.0, could you please fix this issue? otherwise people are forced to work with the old PNP version 1.12.0.
gkDoSt commentedon Feb 8, 2024
Any updates on this?
Im facing the same issue :/
MichaMican commentedon Feb 8, 2024
Same issue here. Absolutely horrible bug tbh.
This is currently a hard blocker for us as for security and regularoty reasons we may not tamper with module files of modules, hence we can't work with the workarround by @JNichNP
HeKr09 commentedon Feb 19, 2024
Is there anything new? This is a really annoying bug.
rvanandel-hcg commentedon Feb 19, 2024
Add me to the list of people who are experiencing this issue. Brand new server with the lastest versions of PNP and Graph modules. There's gotta be a way to fix this. Seems both Graph and PNP teams are blaming the other team rather than coming up with a solution.
crnnr commentedon Feb 21, 2024
Is there a timeline for this? Also facing this issue with workaround not feasible :///
jdarre commentedon Feb 23, 2024
Any update here? As of now, we have to run a single server with PnP.Powershell 2.3.0 and version 1.28 of the Mg-Module.
Legitage commentedon Feb 25, 2024
Our automation scripts are also failing with the same error and for the same reason. Another short-term (not ideal) workaround for using PnP 2.3 is to uninstall the MS Graph module and/or install Microsoft.Graph 2.8.
This DLL version conflict needs to be resolved in way that it doesn't keep happening every few updates.
cyrilchotard commentedon Mar 4, 2024
Same issue for me in Azure Automation with PnP.PowerShell 2.4.0 and Microsoft.Graph 2.15.0
44 remaining items
simonsabin commentedon Feb 14, 2025
Found this to be an awesome solution as it occurs for me in VsCode and the issue is that the PS extension is loading the modules and resulting in the wrong assemblies being loaded.
Essentially you set VSCode to run the file in a new terminal, rather than use the one the extension lives in.
I changed my launch to contain this. The
createTemporaryIntegratedConsolebeing the key entry.HeKr09 commentedon May 5, 2025
Now that there is v3 available: Does anyone knows whether the issue persists?
gautamdsheth commentedon May 23, 2025
Hello all, thank you for the patience. Took quite a while , but we finally removed the Graph dependency which was causing the conflict. Would encourage you to update to the latest nightly builds (3.1.36-nightly or later ) and let us know.
kpinel commentedon May 25, 2025
I'm using 3.1.0 and initial checks show that it's working regardless of the order of connection.
Updating my test environment and will monitor closely
Borgquite commentedon May 27, 2025
@gautamdsheth Since Microsoft.Graph.Core.dll is no longer included in the package for 3.1.34-nightly+, unlike 3.1.33-nightly, and removing this file solves at least one of these errors, I'd say it's looking promising!
From my initial testing I seem to be able to use PnP.PowerShell nightly alongside Graph without deleting files. Thank you!
rvanherk commentedon Jul 24, 2025
We tested with the nightly build 3.1.98 and indeed it now seems to work! Hopefully this fix will be committed soon to a new Build
erickvtorres commentedon Sep 22, 2025
Working 👍🏻
zaaj commentedon Oct 20, 2025
With the nightly builds having a working fix for about 5 months now, what's the timeline looking like for a fixed version making it into a release?
I see workaround about connect-mggraph before the PNP connection, but my uses are more often interactive at a Powershell prompt, so depending on the day's tasks, I might connect in one order vs another, and may have a number of variables stuffed with data I'm working on - leaving those behind to start a new session is a pain.
RobIreland68 commentedon Oct 20, 2025
gautamdsheth commentedon Nov 8, 2025
@zaaj - sorry about the delay. We are currently blocked from a release due to certificate issues. We hope to have it out soon, preferably sometime this month itself .
JakeyNZ commentedon Feb 24, 2026
I am also still having this issue in 3.1.0 Error "Get-MgUserMailFolder_List: Could not load type 'Microsoft.Graph.Authentication.AzureIdentityAccessTokenProvider' from assembly 'Microsoft.Graph.Core, Version=1.25.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'"
Work around is to run Connect-MgGraph and then run a command. This will ensure you are using the right dll. Then you can run Connect-PnPOnline and use both libraries with no issue.
FabienTschanz commentedon Feb 27, 2026
@gautamdsheth Sorry for the direct ping but is there any timeline for a new release of PnP.PowerShell that includes this fix? Appreciate your work on it.
gautamdsheth commentedon May 11, 2026
We just released a new version today after more than a year with this bug fix.
Sorry and apologies for the delay and thanks for the patience , will close this issue now !
Please do let us know if the issue persists with the 3.2.0 , from what i read, it was fixed in the nightly builds and the code related to this is present.