Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2015 Nuget Console not loading #1638

Closed
pete1208 opened this issue Oct 26, 2015 · 68 comments
Closed

VS2015 Nuget Console not loading #1638

pete1208 opened this issue Oct 26, 2015 · 68 comments
Labels
Priority:2 Issues for the current backlog. Resolution:External This issue appears to be External to nuget Type:Bug
Milestone

Comments

@pete1208
Copy link

If do not have any solution open, I can open the package manager console. If I then open a solution, VS2015 crashes.

If I restart visual studio with no package manager console open, then open a solution, then choose package manager console, I get the following error:

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

When this happens I do not get command prompt.
Environment: Win10 32bit, VS2015

Any help would be appreciated.
-Pete

@emgarten
Copy link
Member

Try updating to the latest 3.2.1-rc VSIX here: https://dist.nuget.org/index.html

Does this happen with any solution? Does creating a new project also show this error?

@pete1208
Copy link
Author

I've updated to Package Manager Console Host Version 3.2.1.10581 and the results are the same.

Now here's a something to consider, if I create a powershell project and open that, VS2015 will crash. I can see the project files for a moment, then it crashes.

I've tried re-installing powershell and have net 3.5 & 4.6 installed in windows features. I also disabled my anti-virus with no affect.

@yishaigalatzer
Copy link

Can you share a solution that crashes for you?

@yishaigalatzer
Copy link

Also - Do you have powershell tools installed (https://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597)?

What happens if you remove them?

Any other extension installed on your visual studio?

@pete1208
Copy link
Author

I've had the powershell tools installed, then removed them and tried, then re-installed and tried with the same result.

As far as a project goes, it is as simple as creating a default C# WPF or C# Forms project. Then going using the tools / nuget / console command with the project open. No special references for anything, just the default starter project.

I've repaired VS2015, reinstalled powershell, etc... I wonder if it's a Win10 32 bit issue. Or VMWare issue. The Win10 x86 instance is hosted as guest on VMWare Workstation 12 Pro.

Funny thing is, the console works when no project is open. So I'm guessing the error related to reading what the project info..?

I've played around with changing the execution policy, with no effect.

The only extensions installed from the default are SQL Prompt and Visual Studio Spell Checker.

Any ideas would be appreciated.

@pete1208
Copy link
Author

Ok, i've tried modifying devenv.exe.config. I can now get the console up when a project is open, but there are some errors. However the console prompt does appear.

Changes to config file:

<!-- pete added these entries start -->
<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>

<!-- pete added end -->

Now when the prompt appears and a project is open, i get a few errors:

The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\System32\WindowsPowerShell\v1.0\types.ps1xml(386) : Error in type "System.IO.DirectoryInfo": Exception: Cannot convert the "Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods" value of type "System.String" to type "System.Type".
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\System32\WindowsPowerShell\v1.0\types.ps1xml(393) : Error in type "System.IO.DirectoryInfo": Exception: Cannot convert the "Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods" value of type "System.String" to type "System.Type".
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\System32\WindowsPowerShell\v1.0\types.ps1xml(433) : Error in type "System.IO.FileInfo": Exception: Cannot convert the "Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods" value of type "System.String" to type "System.Type".
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\System32\WindowsPowerShell\v1.0\types.ps1xml(440) : Error in type "System.IO.FileInfo": Exception: Cannot convert the "Microsoft.PowerShell.Commands.InternalSymbolicLinkLinkCodeMethods" value of type "System.String" to type "System.Type".
Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.

Package Manager Console Host Version 3.2.1.10581

Type 'get-help NuGet' to see all available NuGet commands.

PM>

********* so I'm making progress

@pete1208
Copy link
Author

I've just tried it, and the above workaround allows the entity framework to install, so I'm happy.

@mhutch
Copy link

mhutch commented Nov 25, 2015

FWIW, I ran into this on Win10 x64. Googling the error message indicated that when it came up in another context, it could fixed by repairing .NET 3.5, so I went to Windows Optional Features and removed .NET 3.5 entirely. That fixed it in this case too. No idea why though!

@pete1208
Copy link
Author

I tried that uninstalling 3.5, with no luck. I am using using a VM Workstation guest OS Win10 x86. By adding the config lines above it works, if I remove them it fails. There are no error messages when opening the console now too

@yishaigalatzer
Copy link

@pete1208 any chance we can get access to a machine with this failure?

@mrlund
Copy link

mrlund commented Nov 28, 2015

If it helps, I just had the same issue, running 2015 Update 1 RC on Win10 x64, with an MVC project opened in a new instance after another instance open with a Cordova project. I closed both of them down, and reopened just the MVC project, and the console was working again.

@yishaigalatzer
Copy link

The problem is that we cannot get a local repro. Is it possible to get access to a machine this happens on?

@fuxuepeng
Copy link

I was just able to fix this by removing the Nuget extension (via extensions and updates), rebooting, reinstalling it, then rebooting.

@yishaigalatzer
Copy link

@fuxuepeng we have seen some issues with the MEF catalog in Visual Studio not refreshing properly, and a reinstall or a call to devenv /setup resolves it.

now that Update I is out, I recommend to whoever is experiencing this to try again with a fresh install.

@JeremyBP
Copy link

JeremyBP commented Dec 2, 2015

@yishaigalatzer Still the same error: "The type initializer for 'System.Management.Automation.Runspaces.InitialSessionState' threw an exception" when opening the console after a project loaded.

No exception on an empty VS session, the console opened just fine, but if I then open a project, VS goes stucked and I have to restart it.

All above solutions tried with no luck.

Env: Win 10 x64 up to date, VS 2015 CE with U1 & Nuget 3.3.0.167 & Azure SDK 2.8.1

@pete1208
Copy link
Author

pete1208 commented Dec 2, 2015

@yishaigalatzer - I could let you have access to this machine via join.me

@yishaigalatzer
Copy link

@JeremyBP one thing that would be interesting to see is if you have any init.ps1 scripts in your installed nuget packages that are misbehaving. As an experiment can you scan your packages folder for such files and temporarily delete them? (You can always recover by wiping out the packages folder and restoring again).

@pete1208 I'm sick today, but I asked @feiling to work with you. Please email me @ y i g a l a t z @ microsoft.com and I'll forward the contact to him

@feiling
Copy link

feiling commented Dec 2, 2015

@pete1208 please send email to me (feiling at microsoft.com) so that we can figure out how/when I can get access to your machine.

@JeremyBP
Copy link

JeremyBP commented Dec 7, 2015

@yishaigalatzer any progress about it?

@yishaigalatzer
Copy link

I guess not for the last few days, since we where all on vacation on Friday. We will sync again today

@JeremyBP
Copy link

JeremyBP commented Dec 7, 2015

ok
For info this message appears for me when trying to install Json.Net or SQLitePCL on a Xamarin.Android project, more exactly when executing the bundled install.ps1 script.
Workaround was to add each manually, but it's a workaround.
Also, changing PowerShell policies did not change anything.

@feiling
Copy link

feiling commented Dec 7, 2015

@pete1208

The most probable cause seems to that the powershell dlls (System.Management.Automation) that get loaded do not work with nuget.

Since we couldn't repro the problem, I created a simple extension that will list all loaded assemblies in VS:

GetLoadedAssemblies.zip

Download the file, change the extension to vsix and install it. Then in VS, you can run the new command Tools -> Get Loaded Assemblies to save the list of loaded assemblies into a file.

Please run the commands in these scenarios:

  • Open VS, open nuget powershell console, run the command
  • Open VS, open the solution that repros the problem, run the command

You can then upload the output files and we can take a look.

You can also compare the version/location of the powershell assemblies (e.g. System.Management.Automation) yourself and probably you can figure out why the wrong versions get loaded.

On my machine, the assembly is System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, location C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll.

@pete1208
Copy link
Author

pete1208 commented Dec 8, 2015

When I edit the config it (and things work) get the assembly:

System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, location C:\WINDOWS\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

When I don't edit the config:

System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, location C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll

These are the loaded assemblies with each config per your tool.
Not working default config.txt
Working when I modified config.txt

@feiling
Copy link

feiling commented Dec 8, 2015

Could you zip the file C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll and upload it here? If you can't, then pls right click on the dll to get its file version. For reference, the versions on some of my machines are 10.0.10565.0, 10.0.10240.16384.

Also, pls upload the solution/project that repros the problem.

Also, pls copy the info that you get from VS, Help -> About, then click the "Copy Info" button.

@feiling
Copy link

feiling commented Dec 8, 2015

@pete1208 Question about the file 'not working default config.txt': Did you create the file after you opened PowerShell console or after you opened the solution?

@pete1208
Copy link
Author

pete1208 commented Dec 8, 2015

Version Info: about.txt
'Not working default config' -- I opened the powershell window before any project was open. If a project is open, the system crashes.

The other additional requested uploads are here:
System_mgt_auto.zip
TestAppA.zip

@yishaigalatzer
Copy link

@pete1208 one thing we forgot to ask is, can you please remove the spell checker and sql prompt and see if the problem goes away?

Can you poing to the links of these specific extensions in the extension gallery?

@feiling
Copy link

feiling commented Dec 8, 2015

@pete1208 I remember that the project can be opened successfully. The VS only crashes when you try to open PowerShell Console after that. Right? What we need is the list of loaded assemblies after the project is opened, but before you try to open PowerShell Console.

@igrali
Copy link

igrali commented Dec 22, 2015

Do you mean: do Devenv /ResetSettings and reinstall VS again or? I tried doing Devenv /ResetSettings but that didn't help :(

@yishaigalatzer
Copy link

Change the config file is the suggestion.

@igrali
Copy link

igrali commented Dec 22, 2015

Oh, I see. Yeah, it seems that adding those entries to devenv.exe.config solved the problem for me - I was finally able to use Package Manager Console and publish my web app without a crash. Thanks! 😃

@vijayrkn
Copy link

@pete1208 Thanks for sending us the disk with VM. We will take a look at it.

@vijayrkn
Copy link

@pete1208 I tried to repro the issue you mentioned on the machine you provided and I can open the publish dialog with Package manager open without any issues. I also tried publishing the project and it works fine. Is there any repro steps that I am missing here?
publishdialog

@yishaigalatzer
Copy link

Vijay can you run install-package command ?

@pete1208
Copy link
Author

Did you open notepad++ and remove the lines I added to the config? The current config is a work-around one

@vijayrkn
Copy link

I can repro the PMC issue after removing the additional entries from devenv.exe.config. Web publish does work even when this error is thrown. Looking into it.

pmc_issue

@Pray4Wind
Copy link

I had this same error. Very annoying, seemed to appear out of nowhere, then I remembered my machine did one of those lovely "Updates". You know the Poltergeist moment after you go away and come back your screen says, "Hi". Very creepy, Microsoft. Tsk tsk. Well, after poking around some I found this article, which if you follow the steps might solve your problem as well.

Essentially, the "update" had jacked with the security settings in some way. I'd really prefer Microsoft not do these "updates" this way. Nonetheless after setting the ExecutionPolicy and restarting VS, all is well.

Hope this helps.

http://stackoverflow.com/questions/10457039/why-does-executionpolicy-behavior-vary-across-projects-in-visual-studio

@yishaigalatzer
Copy link

@Pray4Wind thanks, but this looks like an unrelated issue to the one reported it (though very possible, something we do not control).

What we are seeing is that there is a stack overflow in the powershell code proper, we have reached out to the power shell team, and we are working on a potential temporary workaround in nuget itself.

@yishaigalatzer yishaigalatzer added the Resolution:External This issue appears to be External to nuget label Jan 4, 2016
@yishaigalatzer
Copy link

UPDATE: We figured out this is a bug in System.Management.Automation 3.0 (on the specific image @pete1208 sent us), which is why the solution by @pete1208 (which basically downgrades to System.Management.Automation 1.0) makes it work again.

The fix is supposed to be released at some point in January as part of the windows update releases, when that happens we will update this issue with exact details on how to acquire it.

@Bilegbayar
Copy link

Same here, if package manager console is OK, publish will crash VS without any notice :(

@cpolitz
Copy link

cpolitz commented Jan 8, 2016

I am experiencing the exact same issue. If I close visual studio and open it fresh and open PackageManager console first it is fine. But then if I try to publish it crashes. If I open it fresh and publish first, that works fine however now PackageManager Console will error as described.

@nkosi23
Copy link

nkosi23 commented Jan 11, 2016

Same problem as @cpolitz here. VS2015, Windows 10, started sometime in the last two weeks without any apparent action from my side.

@yishaigalatzer
Copy link

@Bilegbayar @cpolitz @joeyfr - See above comment, this seems to come from a PowerShell dll that has a bug causing stackoverflow in it. The scenario happens when some new assemblies are being loaded into the main appdomain after this powershell dll is loaded.

There is not much NuGet can do about it, until the Power Shell team releases their fix as part of windows update. I don't have an official date, but I believe it should happen this month.

@nkosi23
Copy link

nkosi23 commented Jan 11, 2016

@yishaigalatzer Thanks mate I didn't get it. Hopefully they will release it soon.

@Spongman
Copy link

can you please post detailed instructions on the workaround? what caused this problem, was it windows update?

@yishaigalatzer
Copy link

@piersh @pete1208 posts a workaround above where we uses binding redirects to force loading powershell 1.0, it is not something we guarantee to work all over, but it seems to be a good bandaid for some people.

Ok, i've tried modifying devenv.exe.config. I can now get the console up when a project is open, but there are some errors. However the console prompt does appear.

Changes to config file:

The problem with it is that it loads an older version of powershell for all of visual studio, and we have no idea what side effects it might have. Feel free to try at your own risk.

@jontyt
Copy link

jontyt commented Jan 13, 2016

For anybody wanting an easy get around the nuget console issue -

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

Simply reinstalling nuget from Visual studio fixed this issue for me.

@yishaigalatzer
Copy link

@pete1208 the fix was released as part of https://support.microsoft.com/en-us/kb/3124263, could you install it and verify the problem is fixed for you?

@pete1208
Copy link
Author

Yes I am working without errors

@nkosi23
Copy link

nkosi23 commented Jan 22, 2016

Same here, this has been fixed

@yishaigalatzer
Copy link

Thanks for validating the fix. This bug was a mystery for a while. Huge thanks to @pete1208 for the help mailing/nailing down a repro

@HalaSaleh-t969344
Copy link

install latest nugget package help me solve this issue
https://www.nuget.org/downloads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:2 Issues for the current backlog. Resolution:External This issue appears to be External to nuget Type:Bug
Projects
None yet
Development

No branches or pull requests