8

打开 Nuget 控制台我收到以下错误:

加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(32) : Error in type "System.Xml.XmlNode": 异常: 由于方法格式,无法创建代码方法。该方法应该是公共的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(44) : Error in type "System.Xml.XmlNodeList": 异常: 由于方法格式,无法创建代码方法。该方法应该是公共的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C: \Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(87):类型“System.DirectoryServices.PropertyValueCollection”中的错误:异常:由于方法格式,无法创建代码方法。该方法应该是公共的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(353):“System.DirectoryServices.DirectoryEntry”类型中的错误:异常: 由于方法格式,无法创建代码方法。该方法应该是公共的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(360):类型“System.DirectoryServices.DirectoryEntry”中的错误:异常:由于方法格式,无法创建代码方法。该方法应该是公共的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(372):“System.IO.DirectoryInfo”类型错误:异常: getter 方法应该是公共的、非 void 的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(399):“System.IO.FileInfo”类型错误:异常: getter 方法应该是公共的、非 void 的、静态的、并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2977):类型“System.Security.AccessControl.ObjectSecurity”中的错误: 例外:getter 方法应该是公共的、非 void 的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2984):类型“System.Security.AccessControl.ObjectSecurity”中的错误: 例外:getter 方法应该是公共的、非 void 的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C: \Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2991):类型“System.Security.AccessControl.ObjectSecurity”中的错误:异常:getter 方法应该是公共的、非 void、静态的,并且有一个参数键入 PSObject。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2998):类型“System.Security.AccessControl.ObjectSecurity”中的错误: 例外:getter 方法应该是公共的、非 void 的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3005):类型“System.Security.AccessControl.ObjectSecurity”中的错误: 例外:getter 方法应该是公共的、非 void 的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3219):类型“Microsoft.PowerShell.DeserializingTypeConverter”中的错误:类型“Microsoft.PowerShell.DeserializingTypeConverter”应该是 TypeConverter 或 PSTypeConverter。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3648):类型“System.Management.Automation.ParameterSetMetadata”中的错误: 例外:getter 方法应该是公共的、非 void 的、静态的,并且有一个 PSObject 类型的参数。加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3733):“System.Management.Automation.FormatViewDefinition”类型错误: 例外:getter 方法应该是公共的、非 void 的、静态的,并且有一个 PSObject 类型的参数。处理 'nuget.psm1' 的模块,列在模块清单 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\QIYNP3CN.X43\Modules\NuGet\NuGet 的字段 'ModuleToProcess' 中。 psd1' 没有被处理,因为在任何模块目录中都没有找到有效的模块。

我可以更新一些 nuget 包,但不能更新 Entity Framework 和其他一些包。对于后者,我收到一个错误:

“...未能初始化 PowerShell 主机。如果您的 PowerShell 执行策略设置为 AllSigned,请先打开包管理器控制台以初始化主机。”

我应该补充一下,我有 Windows 8.1 Pro 64 位。

4

1 回答 1

7

这解释了如何解决我的部分问题(但不知道为什么会发生): http ://social.msdn.microsoft.com/Forums/en-US/0b20e64e-e35f-4d0e-91f1-aebcfda7ebf2/package-manager-控制台加载失败?forum=visualstudiogeneral

所以编辑 devenv.exe.config 并添加以下内容(您可能不需要“runtime”或“assemblyBinding”标签,但你明白了:

 <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <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>
        </assemblyBinding>
    </runtime>

现在这解决了我无法更新 NuGet 包的问题。但是我仍然看到错误,即:

加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(32):类型“System.Xml.XmlNode”中的错误:异常: 由于方法格式,无法创建代码方法。该方法应该是公共的、静态的,并且有一个 PSObject 类型的参数。

底线我一定搞砸了我的 Windows 8.1 Pro 权限。我试图将 Visual Studio 2013 中的链接打开到 Chrome 中,所以我以管理员身份安装了 Chrome ......剩下的就是历史了。

如果我有时间,我会重新安装 Windows 8.1,但上述临时解决方案就是……临时解决方案。

我发现没有 Windows“修复”,而且似乎没有人遇到同样的问题。

希望这对其他人有帮助。

于 2014-05-01T06:53:24.770 回答