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
Copy file name to clipboardExpand all lines: src/powershell/Initialize-Dependencies.ps1
+72-3Lines changed: 72 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -131,10 +131,11 @@ function Initialize-Dependencies {
131
131
Write-Host-Object "`r`n"-ForegroundColor Yellow
132
132
Write-Host-Object '⚠️ Warning: The ZeroTrustAssessment module is designed to run on Windows, in PowerShell 7.'
133
133
Write-Host-Object 'Some pillars require modules that can only run on Windows PowerShell (Windows PowerShell 5.1) with implicit remoting.'-ForegroundColor Yellow
134
-
# skipping module installation.
134
+
Write-Host-Object 'The following Windows-only modules will not be available: AipService, Microsoft.Online.SharePoint.PowerShell'-ForegroundColor Yellow
135
135
#endregion
136
136
}
137
-
elseif (-not$SkipModuleInstallation.IsPresent)
137
+
138
+
if (-not$SkipModuleInstallation.IsPresent)
138
139
{
139
140
Write-Host-Object "`r`n"
140
141
Write-Host-Object ('Resolving {0} dependencies...'-f$allModuleDependencies.Count) -ForegroundColor Green
@@ -229,7 +230,7 @@ function Initialize-Dependencies {
229
230
else {
230
231
Write-Host-Object "`r`n"
231
232
Write-Host-Object 'Asserting MSAL loading order for dependencies...'-ForegroundColor Green
Write-Verbose-Message ('Module with DLLs to load: {0}'-f (([Microsoft.PowerShell.Commands.ModuleSpecification[]]$moduleManifest.RequiredModules).Name -join', '))
235
236
# This method does not necessarily load the right dll (it ignores the load logic from the modules)
@@ -261,6 +262,74 @@ function Initialize-Dependencies {
261
262
}
262
263
}
263
264
}
265
+
266
+
#region Pre-load shared DLLs (newest version wins) to prevent type mismatch errors
267
+
# Multiple modules ship different versions of shared DLLs like Microsoft.IdentityModel.Abstractions.dll.
268
+
# .NET loads the first version it encounters into the default AssemblyLoadContext, and subsequent loads of
269
+
# the same assembly name are ignored. If an older version loads first (e.g., EXO's 8.6.0.0), then code
270
+
# compiled against a newer version (e.g., Graph's Azure.Identity expecting 8.6.1.0) will fail with
271
+
# MissingMethodException because the type signatures don't match.
272
+
# Fix: find and pre-load the newest version of each shared DLL across all dependency modules.
273
+
#
274
+
# IMPORTANT: Only pre-load low-level type-definition DLLs that are shared across all modules in the
275
+
# default AssemblyLoadContext. Do NOT pre-load higher-level libraries like Azure.Identity.dll or
276
+
# Azure.Core.dll here — Az.Accounts uses its own AssemblyLoadContext (ALC) to isolate its versions
277
+
# of those DLLs, and pre-loading them into the default context interferes with ALC type unification,
278
+
# causing "Entry point was not found" errors during Azure authentication.
279
+
$sharedDllNames=@(
280
+
'Microsoft.IdentityModel.Abstractions.dll'
281
+
)
282
+
283
+
# Collect all module base directories from the import order candidates
0 commit comments