Repository navigation
Closed
Labels
Description
Steps to reproduce
Execute this line at the PowerShell Core prompt (I tried this on Window 10 AU with PS Alpha 16):
Add-Type "public class Util { public static int GetVal(System.ConsoleColor color) { return (int)color; }}"Expected behavior
The type is added and is usable.
Actual behavior
I get two errors and the type is not added:
Add-Type : (1) : The type or namespace name 'ConsoleColor' does not exist in the namespace 'System' (are you missing
an assembly reference?)
(1) : >>> public class Util { public static int GetVal(System.ConsoleColor color) { return (int)color; }}
At line:1 char:1
+ Add-Type "public class Util { public static int GetVal(System.Console ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Except
ion
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type : Cannot add type. Compilation errors occurred.
At line:1 char:1
+ Add-Type "public class Util { public static int GetVal(System.Console ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Type], InvalidOperationException
+ FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
[System.ConsoleColor] is available at the prompt so I'm not sure why Add-Type is choking.
Environment data
Name Value
---- -----
BuildVersion 3.0.0.0
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSEdition Core
PSVersion 6.0.0-alpha
PSRemotingProtocolVersion 2.3
CLRVersion
WSManStackVersion 3.0
GitCommitId v6.0.0-alpha.16
SerializationVersion 1.1.0.1
Activity
rkeithhill commentedon Mar 5, 2017
OK, found a workaround (perhaps the solution). This does compile:
iSazonov commentedon Mar 6, 2017
Keith Hill (@rkeithhill) It seems duplicate #1616 Do you agree?
rkeithhill commentedon Mar 6, 2017
Yes, this is duplicate of that issue.