gpt4 book ai didi

.net - PowerShell 3 : Every Command Execution Results In "The type initializer [...] threw an exception" Error

转载 作者:可可西里 更新时间:2023-11-01 14:36:47 25 4
gpt4 key购买 nike

描述

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

最佳答案

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

关于.net - PowerShell 3 : Every Command Execution Results In "The type initializer [...] threw an exception" Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12445422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com