-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Steps to reproduce
- Define some PowerShell classes in a module file (ClassTester.psm1).
- In the manifest, leave RootModule empty and place the module name in the NestedModules key value.
ModuleToProcess = ''
NestedModules = 'ClassTester.psm1'
- In a script, use a Using module statement to import the module and its classes, use the New static method to instantiate one of the classes defined in ClassTester.psm1, and then use New-Object on the same class.
using module ClassTester
$myDog = [Dog]::New('Fido')
$myDog.Bark()
New-Object -TypeName Dog -ArgumentList 'Fluffy'
$myDog.Bark()
Expected behavior
Both the New method and New-Object cmdlet should work.
Actual behavior
New works, but New-Object generates an error.
'Woof!,' said Fido # New method works
New-Object : Cannot find type [Dog]: verify that the assembly containing this type is loaded.
At C:\ps-test\Test-ClassTester.ps1:22 char:11
+ $fluffy = New-Object -TypeName Dog -ArgumentList 'Fluffy'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Environment data
Name Value
---- -----
GitCommitId v6.0.0-alpha.14
PSRemotingProtocolVersion 2.3
BuildVersion 3.0.0.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSVersion 6.0.0-alpha
PSEdition Core
CLRVersion
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime