question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assemblies listed in FileList Module Manifest Property are being Processed.

See original GitHub issue

Steps to reproduce

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 image image

if I remove the .dll values from that list, the logic works fine and the proper dll is loaded.

Expected behavior

No processing of the files in the FileList module manifest property value.

Actual behavior

Im not sure in what way, but he files are being executed or processed.

Environment data

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
vexx32commented, Aug 25, 2020

Oops, my bad. Leaving that one on so we can consider backporting if we feel it’s needed.

1reaction
tomohulkcommented, Aug 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerShell Module file loading files in FileList?
List of all files packaged with this module. As with ModuleList, FileList is to assist you as an inventory list, and is not...
Read more >
about Module Manifests - PowerShell
A module manifest is a PowerShell data file ( .psd1 ) containing a hash table. The keys-value pairs in the hash table describe...
Read more >
Unable To Load PowerShell Module
So I guess the issue seems to occur when a manifest file is in the module directory and is not recognized properly.
Read more >
Understanding and Building PowerShell Modules
The ExportedCommands property contains a list of all the available commands that are exported from the module. You may see some differences ...
Read more >
Chapter 10. Module manifests and metadata
If no file is specified as the ModuleToProcess , then the type shown in the module information object will be Manifest . If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found