簡體   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