Please feel free to provide feedback or file bugs here.

Bug: Loading a file with a class fails if the file's full path contains a comma

Create a file, ClassExample.ps1 with the sample code below. Save the file in a location where the full path does not contain a comma.

Class TestClass {
[void] TestFunction ( [string]$Text = "" ) {
Write-Host $Text
}
}
$TestObj = New-Object TestClass
$TestObj.TestFunction("Hello World!")

Start a PS shell and run the script:

PS C:\Users\don\Desktop\PSBug> .\ClassExample.ps1
Hello World!

Rename the folder or class file and include a comma in the new name and run the script again:

PS C:\Users\llf\Desktop\PSBug> & '.\Class,Example.ps1'
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
At line:1 char:1
+ & '.\Class,Example.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException

Here's the version info of my machine:

PS C:\> gcim win32_operatingsystem | % caption
Microsoft Windows 10 Pro
PS C:\> $PSVersionTable.PSVersion

Major Minor Build Revision
----- ----- ----- --------
5 1 16299 19

2 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    donlassini shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base