8

Opening up Nuget Console I receive the following error:

The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(32) : Error in type "System.Xml.XmlNode": Exception: Cannot create a code method because of the method format. The method should be public, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(44) : Error in type "System.Xml.XmlNodeList": Exception: Cannot create a code method because of the method format. The method should be public, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(87) : Error in type "System.DirectoryServices.PropertyValueCollection": Exception: Cannot create a code method because of the method format. The method should be public, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(353) : Error in type "System.DirectoryServices.DirectoryEntry": Exception: Cannot create a code method because of the method format. The method should be public, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(360) : Error in type "System.DirectoryServices.DirectoryEntry": Exception: Cannot create a code method because of the method format. The method should be public, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(372) : Error in type "System.IO.DirectoryInfo": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(399) : Error in type "System.IO.FileInfo": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2977) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2984) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2991) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(2998) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3005) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3219) : Error in type "Microsoft.PowerShell.DeserializingTypeConverter": Type "Microsoft.PowerShell.DeserializingTypeConverter" should be a TypeConverter or an PSTypeConverter. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3648) : Error in type "System.Management.Automation.ParameterSetMetadata": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3733) : Error in type "System.Management.Automation.FormatViewDefinition": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject. The module to process 'nuget.psm1', listed in field 'ModuleToProcess' of module manifest 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\QIYNP3CN.X43\Modules\NuGet\NuGet.psd1' was not processed because no valid module was found in any module directory.

I can update some of the nuget packages but not Entity Framework and some other packages. With the latter I receive an error:

"...failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first."

I should add I have Windows 8.1 Pro 64 bit.

Rob
  • 3,074
  • 4
  • 31
  • 32

1 Answers1

7

This explains how to resolve part of my issue (but no why it had happened): http://social.msdn.microsoft.com/Forums/en-US/0b20e64e-e35f-4d0e-91f1-aebcfda7ebf2/package-manager-console-failed-to-load?forum=visualstudiogeneral

So edit devenv.exe.config and add the following (you may not need the "runtime" nor "assemblyBinding" tags but you get the idea:

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

Now this resolves my issue of not being able to update NuGet packages. However I still see errors i.e.:

The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(32) : Error in type "System.Xml.XmlNode": Exception: Cannot create a code method because of the method format. The method should be public, static, and have one parameter of type PSObject.

Bottom line I must have screwed up my Windows 8.1 Pro permissions. I was trying to open up links within Visual Studio 2013 into Chrome so I installed Chrome as administrator... the rest is history.

If I had time I would reinstall Windows 8.1 but the aforementioned temp solution is just that... a temp solution.

I found no windows "fix" and no-one appears to have had the same issue.

Hope this sort of helps anyone else.

Rob
  • 3,074
  • 4
  • 31
  • 32
  • 2
    Can't believe this, but just had the same issue with Visual Studio 2015! So once again added the same config changes! – Rob Aug 05 '15 at 05:38
  • I had it in VS2015 too. Maybe after some PowerShell module installation of Visual Studio plugin. – ForNeVeR Oct 09 '15 at 17:38
  • 1
    Just observed exactly same errors. My solution is pretty simple: I've uninstalled the PowerShell Extensions for Visual Studio 2015. – dymanoid Jan 26 '16 at 13:24
  • it seems to happen only on machine with **Insider Preview Build** correct me if i'm wrong – Nerdroid May 05 '16 at 03:02
  • @Moes, I see it on regular Windows 10 Pro. – UserControl Jul 19 '16 at 08:18
  • @Moes, I have. Actually it made the problem permanent. So far repairing VS and then adding those binding redirects seems to be working. – UserControl Jul 19 '16 at 10:10
  • 1
    @Rob I do have the same issue on a fully patched Win10 Pro machine. I tried repairing VS installation, uninstall/reinstall NuGet Package Manager. Nothing helps, so far. – BladeWise Jul 27 '16 at 14:16
  • 1
    I had to do this to my local AppData dev config file. Updating the config file next to the exe didn't work. Here is the folder path for VS 2015: %LOCALAPPDATA%\Microsoft\VisualStudio\14.0\devenv.exe.config – Andrew C Dec 20 '16 at 05:12
  • @Andrew C, thanks a lot, I had this problem for more than half a year, from time to time, I tried everything I could find, and repairing VS 2015 or installing VS 2017 didn't change anything, but you did !! – Yet Another Code Maker Mar 31 '17 at 20:15
  • @AndrewC updating the file `devenv.exe.config` in `LocalAppData` path worked for me using VS2013 Update 5. Full path is `%LocalAppData%\Microsoft\VisualStudio\12.0\devenv.exe.config` – Felipe Romero Nov 27 '18 at 00:20