简体   繁体   English

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

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

Description 描述

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的事情。)

Output Of The Shell 壳牌的输出

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:\\> _

My Question 我的问题

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.

相关问题 &#39;&#39;的类型初始值设定项引发了异常 - The type initializer for '' threw an exception 网站-“静态类”的类型初始值设定项引发异常 - Website - The type initializer for 'Static Class' threw an exception “Npgsql.PoolManager”的类型初始值设定项引发异常 - The type initializer for 'Npgsql.PoolManager' threw an exception &#39;PublicDomain.TzTimeZone&#39;的类型初始值设定项引发了异常 - The type initializer for 'PublicDomain.TzTimeZone' threw an exception .net 4.8:&#39; 的类型初始值设定项<Module> &#39;抛出异常 - .net 4.8: The type initializer for '<Module>' threw an exception 在实体框架模型中引发异常的类型初始值设定项? - The type initializer for threw an exception in entity framework model? 无法加载Exchange PowerShell管理单元:“Microsoft.Exchange.Data.Directory.Globals”的类型初始值设定项引发异常 - Cannot load Exchange powershell snap-in: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception 从C#错误调用Matlab函数错误:“ tes.tambah”的类型初始值设定项引发了异常 - Call Matlab Function from C# error : The type initializer for 'tes.tambah' threw an exception EF DbContext的Linqpad错误:&#39;System.Data.Entity.Internal.AppConfig&#39;的类型初始值设定项引发异常 - Linqpad Error with EF DbContext: The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception &#39;System.ServiceModel.Diagnostics.TraceUtility&#39;的类型初始值设定项引发了异常 - The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM