【发布时间】:2012-09-08 20:27:40
【问题描述】:
说明
几个月前,我在我的系统上安装了新的 PowerShell 版本。从那以后,每次我使用 shell 时都会发生一些奇怪的事情。它不会影响功能,但它让我感到困扰和困扰,因为每次在命令执行结束时我都必须看到红色错误消息。
(我不是 .NET 专家,我从未对 .NET 或 PowerShell 做过任何意想不到的事情。)
Shell 的输出
PS C:\\> my-cmdlet
Cmdlet-Ausgabe...
Der Typeninitialisierer für "System.Management.Automation.HostUtilities" hat eine Ausnahme verursacht.
PS C:\\> _
这是德语版的:
PS C:\\> my-cmdlet
Cmdlet output...
The type initializer for "System.Management.Automation.HostUtilities" threw an exception.
PS C:\\> _
我的问题
有没有办法停止这些错误消息(不会影响 PowerShell v3 的功能)? - 谢谢。
(如果您需要有关我的 PowerShell 的更多信息,请编写命令并描述您需要哪些信息。)
(我希望我想问的问题很清楚。但是,如果不是,请写一个评论来描述不清楚的地方!)
更新:
(Shellin-/运行时输出$error[0].exception.tostring())
PS %> my-cmdlet
Cmdlet-Ausgabe...
Der Typeninitialisierer für "System.Management.Automation.HostUtilities" hat eine Ausnahme verursacht.
PS %> $error[0].exception.tostring()
Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat.
In Zeile:1 Zeichen:1
+ $error[0].exception.tostring()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Der Typeninitialisierer für "System.Management.Automation.HostUtilities" hat eine Ausnahme verursacht.
PS %> _
那个德语版的:
PS %> my-cmdlet
Cmdlet-Output...
The type initializer for "System.Management.Automation.HostUtilities" threw an exception.
PS %> $error[0].exception.tostring()
You cannot call a method on a null-valued expression.
On line:1 char:1
+ $error[0].exception.tostring()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
The type initializer for "System.Management.Automation.HostUtilities" threw an exception.
PS %> _
【问题讨论】:
-
请将
$error[0].exception.tostring()的输出添加到您的问题中。您应该在导致错误后直接运行它。 -
@x0n 我扩展了与此相关的问题文本。
标签: .net windows shell powershell powershell-3.0