几个月前我在我的系统上安装了新的PowerShell版本。从那以后,每次使用shell时都会发生奇怪的事情。它并没有给功能带来麻烦,但它让我感到麻烦和烦恼,因为每次执行命令结束时我都要看到一条红色的错误信息。
(我不是.NET专家,我从来没有做过一些无法用于.NET或PowerShell的事情。)
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的更多信息,请编写命令并描述您需要的信息。)
(我希望很清楚我想问的问题。但是,如果不是,请写一篇评论,说明不清楚的地方!)
更新
(运行$error[0].exception.tostring()
时的Shellin- /输出)
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 %> _
答案 0 :(得分:0)
在“类型初始化程序”(即静态构造函数)中运行的唯一代码是从资源字符串填充建议数组的东西。在我看来,资源文件已被删除或损坏,或者您的系统的语言/文化设置有些奇怪,以防止特定于文化的资源检索工作。我建议重新安装PowerShell 3.0和/或验证操作系统的语言是否与PowerShell安装程序的语言相同。遗憾!
答案 1 :(得分:0)
我似乎记得在测试期间我曾经看过这个(在VM中!) - 由于某种原因,这是一个duff安装。你可以重新安装吗?
这当然不是预期的行为。
就个人而言,我发现6-18个月的完整重新安装是一个好主意,因为我玩了很多测试版软件。本周早些时候我的笔记本电脑得到了重新安装处理,并且运行得更好!