Forum Discussion
Exchange online and MGGraph are interfering
- Jul 30, 2024
The issue is that ExchangeOnlineManagement 3.5.1 uses version 8.0.23.53103 of System.Text.Json.dll where 3.4.x doesn't use System.Text.Json.dll at all, hence there's no conflict with version 6.0.21.52210 used by the Microsoft.Graph.Authentication module.
Cheers,
Lain
Hi, Peter.
This isn't a particularly uncommon scenario and is caused by different PowerShell modules being aligned to different underlying .NET libraries.
The key is to find which versions of which PowerShell modules can happily coexist, which is not as simple as saying "use the latest version of each module", since they're released on their individual cadences. It's not like the authors of one module go out and test interoperability with all the available versions of every other module available.
In you case, the error near the bottom of your second dump indicates there's a conflict on the constructor of the [System.Text.Json.Utf8JsonReader] struct. I can't read the language the error's in but it doesn't really matter.
If you load only the Exchange Online module and run the following command, what version information does it produce? And then if you close that PowerShell window, open another, then load the Graph module and re-run the same command, what version information does that yield?
I'd expect the file locations and the version numbers will differ, and this will be where the error is coming from.
Whichever module is loaded first will likely work since it's loaded the version of System.Text.Json.dll it's aligned to, while the second module won't be able to load its own version since a given module is only loaded once into the PowerShell process.
Diagnostic command
(Get-Item -Path "$([System.Text.Json.Utf8JsonReader].Assembly.Location)").VersionInfo;
Ultimately, even knowing this version information doesn't intrinsically provide a solution. It's use is in determining which modules are likely to be compatible using the "load one module and check, then load the other module and check" approach.
For example, if you test with different versions of the Exchange and Graph modules and find both settle on a common version number, then this specific error should go away (though there's nothing to say a different module conflict won't arise).
Honestly, it'd probably be faster to simply try the last two or three versions of each until you find a working combination, but the above command will assist you if you want to go about it more forensically.
Cheers,
Lain