下面的代码,能执行成功, 但是总是有如下错误, 求大佬解惑, 谢谢
Add-Type : Cannot add type. The type name 'ClassLibrary1.Class1' already exists.
At line:15 char:1
+ Add-Type -TypeDefinition $code
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (ClassLibrary1.Class1:String) [Add-Type], Excep
tion
+ FullyQualifiedErrorId : TYPE_ALREADY_EXISTS,Microsoft.PowerShell.Commands.AddTypeCommand | $code = @ | | namespace ClassLibrary1 | | { | | public class Class1 | | { | | public static void SayHello() | | { | | System.Console.WriteLine("hello world"); | | } | | } | | } | | | | | | Add-Type -TypeDefinition $code | | | | [ClassLibrary1.Class1]::SayHello()COPY |
|