繁体   English   中英

PowerShell 3:每个命令执行结果“类型初始化程序[...]引发异常”错误

[英]PowerShell 3: Every Command Execution Results In “The type initializer […] threw an exception” Error

描述

几个月前我在我的系统上安装了新的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 %> _

在“类型初始化器”(即静态构造函数)中运行的唯一代码是从资源字符串填充一组建议的东西。 在我看来,资源文件已被删除或损坏,或者您的系统的语言/文化设置有些奇怪,以防止特定于文化的资源检索工作。 我建议重新安装PowerShell 3.0和/或验证操作系统的语言是否与PowerShell安装程序的语言相同。 抱歉!

我似乎记得在测试期间我曾经看过这个(在VM中!) - 由于某种原因,这是一个duff安装。 你能重新安装吗?

这当然不是预期的行为。

就个人而言,我发现6-18个月的完整重新安装是一个好主意,因为我玩了很多测试版软件。 我的笔记本电脑本周早些时候得到了重新安装处理,运行得更好!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM