none
Nuget can't initialize PowerShell

    Question

  • Hello!
    I have an issue with Visual Studio 2015. Can't open Package Management Console because issues:

    The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : 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(3014) : 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(3021) : 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(3028) : 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(3035) : 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 term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    I found a lot of articles in the Internet, but nothing help!
    Any advice or ideas?

    PS Image can be opened in a new tab by right clicking and selecting a Open Image in New Tab command.

    • Edited by AndyVGa Tuesday, December 06, 2016 9:06 PM
    Tuesday, December 06, 2016 8:35 PM

Answers

  • I found the cause. It was a PowerShell manager for Visual Studio. It makes some changes and overwrites NuGet settings. After I completely deleted it and %AppData%\Microsoft\VisualStudio it works stable for me!

    Andy Guyowy

    • Marked as answer by AndyVGa Wednesday, December 14, 2016 5:29 AM
    Wednesday, December 14, 2016 5:29 AM

All replies

  • Hi AndyVGa,

    When do you get this exception, after installing Visual Studio 2015 or after using Visual Studio 2015 for a while?

    If this issue occurs after using Visual Studio 2015 for a while, I suggest you uninstall and reinstall your NuGet Package Manager for Visual Studio 2015. And make sure you are installing the latest version (version 3.5) for your Visual Studio.

    Then please also try open your PowerShell to test whether your PowerShell could working fine. This could help us confirm whether this issue caused by the NuGet Package Manager or the PowerShell.

    If this issue occurs after installing VS2015, please make sure you have installed the latest version of Visual Studio 2015 (version 14.0.25431.01) and make sure your Windows has installed all Updates. Because there is a known bug for PowerShell on Windows 10.

    And it also has some known issue on NuGet about ObjectSecurity exception. Please follow the solution discussed on this page.

    http://stackoverflow.com/questions/12638289/embedding-powershell-v2-0-in-net-app-on-windows-8-rtm

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 07, 2016 7:59 AM
    Moderator
  • Hi Weiwei,
    I have a version of Visual Studio 2015 Professional as 14.0.25431.01 Update 3.
    The PowerShell console inside VS is working fine for me.
    I have already installed NuGet 3.5 but it didn't work. Now I have a version 3.4.4.1321. It is the latest one for an automatic installation with Extensions and Updates.
    Also, I have modified the devenv.exe.config file as suggested. There is no result.

    Updated NuGet to version 3.5 and it is no result again.

    Andy Guyowy


    • Edited by AndyVGa Wednesday, December 07, 2016 6:03 PM
    Wednesday, December 07, 2016 1:23 PM
  • Hi Andy,

    Do you install nay PowerShell extensions for your Visual Studio 2015?

    If installed, please try uninstall these PowerShell extensions for Visual Studio to check whether the issue causes by the extensions or not.

    In addition, please try repair your Visual Studio 2015 to check whether there has any installation issue for your Visual Studio 2015.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 08, 2016 8:04 AM
    Moderator
  • I have reinstalled everything from scratch last night.
    I have Visual Studio Professional Version 14.0.25431.01 Update 3
    I have NuGet Version 3.5.0.1996

    I still have an issue with a NuGet Console. PowerShell is working fine.



    Andy Guyowy

    Friday, December 09, 2016 3:23 PM
  • Hi Andy,

    Does the Package Manager Console window work fine before?

    If it working fine before, please check whether you have installed any updates for your Windows. You could check the installed Updates from Control Panel -> Programs and Features -> View Installed Updates.

    If it doesn't work after installing Visual Studio 2015, please use http://aka.ms/vscollect  to gather the VS and .Net Frameowrk installation logs. After using it, you will find vslogs.cab from %temp% folder. Please upload the file to Onedrive and share the link here.

    In addition, please check your Windows version. I'm using Windows 10 version 1607 (OS Build 14393.447). And the Package Manager Console also working fine on Windows 10 version 10.0 (Build 10240). If any difference, please feel free to let me know.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 12, 2016 7:23 AM
    Moderator
  • Hi Weiwei,

    At Summer I had Windows 7 and everything working fine.
    Approximately, in September I switched to Windows 10. Approximately at the end of September.
    Currently I have Windows 10 Home, Version 1607, OS Build 14393.479 .
    I have been working with an architecture and didn't use Visual Studio 2015 a lot. In particular, I didn't use ASP.NET . Recently I started to create ASP.NET MVC web site and found that issue.
    As I explained earlier, I have reinstalled Visual Studio 2015 this weekend and nothing changed. I still have the same issue.

    Please, find my logs:
    https://drive.google.com/open?id=0B4PdanecMIjWUDNOQWRGT1JVdjA

    Sincerely,

    Andy Guyowy

    Monday, December 12, 2016 6:49 PM
  • Hi Andy,

    After analysis your Visual Studio installation log, I don't find any errors about NuGet Packages Manager for Visual Studio and your Visual Studio is installed correctly. So the problem is not related to Visual Studio installation.

    Do you have tried open Manage NuGet Packages UI from PROJECT -> Manage NuGet Packages?

    If the Manager UI could be opened correctly, the NuGet Packages Manager should be fine. The issue should related to the PowerShell. Otherwise, the issue is caused by the NuGet Packages Manager.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 13, 2016 5:37 AM
    Moderator
  • Hi Weiwei,
    I can open a PowerShell console. I can open NuGet manager from a project.
    However, when I tried to load jQuery, for example, I have the same message as when trying to open Package Management Console. 
    The message is about that PowerShell couldn't be initialized. I have posted a picture before.

    Andy Guyowy

    Tuesday, December 13, 2016 5:48 AM
  • Hi Andy,

    According to all above troubleshooting, this issue should be more related to the PowerShell.

    Please check your PowerShell version, does it 32 bit or 64 bit? Please make sure your PowerShell version is the same with Visual Studio. The Visual Studio should be 32 bit.

    In addition, please run your Visual Studio as administrator to check whether this issue caused by the permissions.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 14, 2016 2:41 AM
    Moderator
  • Hi Weiwei,
    I always run a Visual Studio as an Administrator because I use unit tests.

    I am attaching results of checking versions.

    Unfortunately for now I don't know what else I can check.

    Sincerely,


    Andy Guyowy

    Wednesday, December 14, 2016 3:07 AM
  • Hi Weiwei !
    After all it is working!
    I removed a PowerShell package from Visual Studio and started to reinstall NuGet from the version 3.3 .
    It was working and proposed to make an update. I did.
    Now it is working fine!
    Unfortunately I have no ideas what it was...



    Thank you very much for your help !!!

    Sincerely,

    Andy Guyowy

    Wednesday, December 14, 2016 5:09 AM
  • I found the cause. It was a PowerShell manager for Visual Studio. It makes some changes and overwrites NuGet settings. After I completely deleted it and %AppData%\Microsoft\VisualStudio it works stable for me!

    Andy Guyowy

    • Marked as answer by AndyVGa Wednesday, December 14, 2016 5:29 AM
    Wednesday, December 14, 2016 5:29 AM