I have a WinSCP PowerShell Module Wrapper, and I was implementing some functionality to load one WinSCPnet.dll if it is PowerShell core, and a different one if it is PowerShell desktop. And I kept getting errors stating that the assembly of the same name was already loaded.
Turns out, I had both of the assemblies listed in the Module Manifest FileList property, after removing them from there, the logic to add the correct assembly works fine. Per this link, that property should be for inventory only, and should not process the files in the value: https://docs.microsoft.com/en-us/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest?view=powershell-7#module-manifest-elements
# Assembly loading logic from WinSCP.psm1
$moduleRoot = Split-Path -Path $MyInvocation.MyCommand.Path
switch ($PSVersionTable.PSEdition) {
"Core" {
#Add-Type -Path "${moduleRoot}\lib\netstandard2.0\WinSCPnet.dll"
add-type -path ./Documents/github/WinSCP/WinSCP/lib/netstandard2.0/WinSCPnet.dll
break;
}
"Desktop" {
Add-Type -Path "${moduleRoot}\lib\net40\WinSCPnet.dll"
break;
}
default {
Write-Error -Message "Failed to find a compatiable WinSCP Assembly."
exit
}
}
When the FileList property in the manifest has those files listed in the value, I get the "Assembly with the same name is already loaded" error


if I remove the .dll values from that list, the logic works fine and the proper dll is loaded.
No processing of the files in the FileList module manifest property value.
Im not sure in what way, but he files are being executed or processed.
PS /Users/thomas> $psversiontable
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Darwin 20.0.0 Darwin Kernel Version 20.0.0: Thu…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@tomohulk can you verify if this still happens on the latest preview release? I know there were some changes made to avoid loading native libraries from the FileList, but I think that may have also impacted cases like this (positively), so would be good to check just in case. 🙂
I believe this was fixed in https://github.com/PowerShell/PowerShell/pull/12968, but the fix was not backported to 7.0.
@vexx32 can I run the preview along side the RC to test?
Yep!
sorry took so long, but I finally got time to install 7.1.6, and it does seem this is fixed in that release. thanks.
Oops, my bad. Leaving that one on so we can consider backporting if we feel it's needed.