2015-12-21 65 views
6

私はASP.NET MVCの単純なレコード管理Webアプリケーションで作業していました。ビルドは成功しました。しかし、私がPackage Manager Consoleに行くと、私はいつもこのエラーを受け取ります。'System.Management.Automation.Runspaces.InitialSessionState'の型初期化子が例外をスローしました

The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception. 

誰かがこのエラーを私に説明できますか?私はいつもそれを取得し、それは開発で私を悩ます。前もって感謝します。

+0

あなたは[ここ](https://github.com/NuGet/Home/issues/1638)で提案されているものが関連しているかどうか試してみることができます。それ以外の場合は、Visual Studioで[ActivityLog](https://msdn.microsoft.com/library/ms241272.aspx)を作成します。これには通常、エラーに関する技術情報が含まれています。 –

+0

私は同じ問題を抱えていましたが、Visual Studioを再起動してしまいました。Visual Studio Community 2013を使用しています。 – Dev

答えて

4

次の情報は、このVisual StudioのNuGetコンソールバグレポートのチケットのスレッドから収集したhttps://github.com/NuGet/Home/issues/1638

原因Yishai Galatzer(マイクロソフト)からthis commentパー

、問題は、スタックオーバーフローのバグによって引き起こされますSystem.Management.Automation 3.0の一部であるPowerShell DLLに含まれています。バグのある更新されたDLLは、過去数週間のうちにWindows Updateの一部として配布されたようです。

また、Yishai Galatzerのanother commentによると、今月後半(2016年1月)にPowerShellチームが修正をリリースする予定です。

回避策/一時的な解決策

"pete1208" posted以前、同じスレッドで以下の回避策:お使いのVisual Studioフォルダに

は、ファイルdevenv.exe.configのバックアップコピーを作成します。

<!-- WORKAROUND START for NuGet Console error: 
    "The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception" 
    Author: pete1208 from https://github.com/NuGet/Home/issues/1638 --> 
<dependentAssembly> 
     <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" /> 
     <publisherPolicy apply="no" /> 
     </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" /> 
     <publisherPolicy apply="no" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" /> 
     <publisherPolicy apply="no" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" /> 
     <publisherPolicy apply="no" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" /> 
     <publisherPolicy apply="no" /> 
    </dependentAssembly> 
    <dependentAssembly> 
     <assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" /> 
     <publisherPolicy apply="no" /> 
    </dependentAssembly> 
<!-- WORKAROUND END --> 

は(おそらくにお好みのテキストエディタの管理者-上昇したバージョンが必要になります:

その後、元devenv.exe.configファイルで、次のようちょうど開封後assemblyBinding要素を挿入ファイルをVisual Studioフォルダに保存します)。

その後、Visual Studioを再起動します。

再度per Yishai Galatzer、この回避策の効果は、バインディングリダイレクトを使用してPowerShell 1.0を強制的に読み込むことです。

私は回避策を試しましたが、それは私のために働いた。私のVisual Studio 2013のMy Package Manager Consoleがもう一度機能します。

NuGetのバグスレッドに注目し、System.Management.Automationの修正プログラムを適用したWindows Updateが公開されたことをお知らせしたら、私の回避策を取り戻すつもりですdevenv.exe.configファイル。

更新

修正がYishai Galatzer(マイクロソフト)ごとに、January 12, 2016 Windows Updateにリリースされました。

関連する問題