[英]PowerShell 3: Every Command Execution Results In “The type initializer […] threw an exception” Error
I've installed the new PowerShell version on my system a few months ago. 几个月前我在我的系统上安装了新的PowerShell版本。 Since that, something strange happens every time I use the shell.
从那以后,每次使用shell时都会发生奇怪的事情。 It doesn't trouble the functionality, but it's troubling and bugging me because every time at the end of a command execution I have to see the a red error message.
它不会给功能带来麻烦,但它让我感到不安和烦恼,因为每次在命令执行结束时我都要看到一条红色的错误信息。
(I'm not a .NET expert and I never did something unanticipated to .NET or PowerShell.) (我不是.NET专家,我从未做过一些无法用于.NET或PowerShell的事情。)
PS C:\\> my-cmdlet
Cmdlet-Ausgabe...
Der Typeninitialisierer für "System.Management.Automation.HostUtilities" hat eine Ausnahme verursacht.
PS C:\\> _
That's the German version of: 这是德语版:
PS C:\\> my-cmdlet
Cmdlet output...
The type initializer for "System.Management.Automation.HostUtilities" threw an exception.
PS C:\\> _
Is there any way to stop these error messages (without troubling the functionality of PowerShell v3)? 有没有办法阻止这些错误消息 (没有麻烦PowerShell v3的功能)? - Thanks.
- 谢谢。
(If you need more information about my PowerShell, please write a command and describe which information you need.) (如果您需要有关我的PowerShell的更多信息,请编写命令并描述您需要的信息。)
(I hope it's clear what I wanted to ask. However, if it isn't, please write a comment describing what's unclear!) (我希望很清楚我想问的问题。但是,如果不是,请写一个评论,说明不清楚的地方!)
UPDATE: 更新:
(Shellin-/output while running $error[0].exception.tostring()
) (运行
$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 %> _
That the German version of: 那个德文版:
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 %> _
The only code that runs inside the "type initializer" (ie the static constructor) is something that populates an array of suggestions from resource strings. 在“类型初始化器”(即静态构造函数)中运行的唯一代码是从资源字符串填充一组建议的东西。 In my opinion, either the resource files have been deleted or corrupted, or there is something odd about your system's language/culture settings that prevent culture-specific resource retrieval from working.
在我看来,资源文件已被删除或损坏,或者您的系统的语言/文化设置有些奇怪,以防止特定于文化的资源检索工作。 I suggest either reinstalling PowerShell 3.0 and/or verifying that the language of your operating system is the same as the language of the PowerShell installer.
我建议重新安装PowerShell 3.0和/或验证操作系统的语言是否与PowerShell安装程序的语言相同。 Sorry!
抱歉!
I seem to recall I saw this (in a VM!) once during the beta - it was a duff install for some reason. 我似乎记得在测试期间我曾经看过这个(在VM中!) - 由于某种原因,这是一个duff安装。 Can you do a re-install??
你能重新安装吗?
This is certainly NOT intended behavior. 这当然不是预期的行为。
Speaking personally, I find a complete re-install ever 6-18 months is a good idea as I do play with a lot of beta software. 就个人而言,我发现6-18个月的完整重新安装是一个好主意,因为我玩了很多测试版软件。 My laptop got the re-install treatement earlier this week and is running much better!
我的笔记本电脑本周早些时候得到了重新安装处理,运行得更好!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.