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

Startup fails when incorrect Serilog assembly picked up from the GAC #2538

Closed
Robbie-sys opened this issue Mar 9, 2020 · 23 comments
Closed
Labels

Comments

@Robbie-sys
Copy link

Robbie-sys commented Mar 9, 2020

System Details Output

3/9/2020 9:43:57 AM [NORMAL] - Visual Studio Code v1.42.1 64-bit
3/9/2020 9:43:57 AM [NORMAL] - PowerShell Extension v2020.3.0
3/9/2020 9:43:57 AM [NORMAL] - Operating System: Windows 64-bit
3/9/2020 9:43:57 AM [NORMAL] - Language server starting --
3/9/2020 9:43:57 AM [NORMAL] -     PowerShell executable: C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
3/9/2020 9:43:57 AM [NORMAL] -     PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1583765037-2b1f8bdb-41e1-437c-8715-1fb9f64306201583765036935\EditorServices.log' -SessionDetailsPath 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-24472-560475' -FeatureFlags @() 
3/9/2020 9:43:57 AM [NORMAL] -     PowerShell Editor Services args: Import-Module 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2020.3.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\logs\1583765037-2b1f8bdb-41e1-437c-8715-1fb9f64306201583765036935\EditorServices.log' -SessionDetailsPath 'c:\Users\Robbie Johnson\.vscode\extensions\ms-vscode.powershell-2020.3.0\sessions\PSES-VSCode-24472-560475' -FeatureFlags @() 
3/9/2020 9:43:57 AM [NORMAL] - powershell.exe started.
3/9/2020 9:43:57 AM [NORMAL] - Waiting for session file
3/9/2020 9:45:58 AM [NORMAL] - Error occurred retrieving session file
3/9/2020 9:45:58 AM [NORMAL] - Language server startup failed.
3/9/2020 9:45:58 AM [ERROR] - The language service could not be started: 
3/9/2020 9:45:58 AM [ERROR] - Timed out waiting for session file to appear.

Issue Description

Hey everyone, running into an issue where I can't execute from the editor.
Powershell works as expected from the terminal. I've uninstalled and reinstalled the extension as well as Visual Studio Code. Any help would be greatly appreciated!

@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 9, 2020
@Robbie-sys
Copy link
Author

Update;
Uninstalling PowerShell Extension v2020.3.0 and reinstalling PowerShell Extension v2019.12.0 fixed the issue.

@TylerLeonhardt
Copy link
Member

Thanks for the info! Can you also attach the logs here so we can get a better idea of what's going on?

@Robbie-sys
Copy link
Author

Robbie-sys commented Mar 9, 2020

Logs attached. The issue appears to only happen with the most recent version.

vscode-powershell.log
StartEditorServices.log

@rjmholt
Copy link
Contributor

rjmholt commented Mar 9, 2020

[ERR]: Exception encountered starting EditorServices. Exception logged in D:\a\1\s\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 247 in EndProcessing:
System.MissingMethodException: Method not found: 'Serilog.LoggerConfiguration Serilog.FileLoggerConfigurationExtensions.File(Serilog.Configuration.LoggerSinkConfiguration, System.String, Serilog.Events.LogEventLevel, System.String, System.IFormatProvider, System.Nullable`1<Int64>, Serilog.Core.LoggingLevelSwitch, Boolean, Boolean, System.Nullable`1<System.TimeSpan>, Serilog.RollingInterval, Boolean, System.Nullable`1<Int32>, System.Text.Encoding, Serilog.Sinks.File.FileLifecycleHooks)'.
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesServerFactory.<>c__DisplayClass0_0.<Create>b__0(LoggerSinkConfiguration config)
   at Serilog.Configuration.LoggerSinkConfiguration.Wrap(LoggerSinkConfiguration loggerSinkConfiguration, Func`2 wrapSink, Action`1 configureWrappedSink, LogEventLevel restrictedToMinimumLevel, LoggingLevelSwitch levelSwitch)
   at Serilog.LoggerConfigurationAsyncExtensions.Async(LoggerSinkConfiguration loggerSinkConfiguration, Action`1 configure, IAsyncLogEventSinkMonitor monitor, Int32 bufferSize, Boolean blockWhenFull)
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesServerFactory.Create(String logPath, Int32 minimumLogLevel, IObservable`1 hostLogger)
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner..ctor(HostLogger logger, EditorServicesConfig config, ISessionFileWriter sessionFileWriter, IReadOnlyCollection`1 loggersToUnsubscribe)
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesLoader.LoadAndRunEditorServicesAsync()
   at Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing()

This looks like something to go on!

@rjmholt
Copy link
Contributor

rjmholt commented Mar 9, 2020

This is quite mysterious. Perhaps we're picking up the wrong version of a dependency from the GAC?

@rjmholt rjmholt reopened this Mar 9, 2020
@rjmholt rjmholt changed the title Language server startup failed Startup fails with: System.MissingMethodException: Method not found: Serilog.FileLoggerConfigurationExtensions.File Mar 9, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

@Robbie-sys can you try following the steps in #2397 (comment) and letting me know if that helps with your issue?

@Robbie-sys
Copy link
Author

Hey @rjmholt - after installing the Powershell preview and disabling the Powershell extension the problem persists.

StartEditorServices.log
vscode-powershell.log

@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

@Robbie-sys Can you set the log level to diagnostic in your configuration and grab the logs again? That will help me work out if the reason Serilog is getting the MissingMethodException is that it’s coming from somewhere else

@Robbie-sys
Copy link
Author

@rjmholt - Oops, please find the new logs attached.

StartEditorServices.log
vscode-powershell.log

@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

Thanks for that!

There it is:

[DBG]: Loaded 'Serilog.Sinks.File, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' from 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Serilog.Sinks.File\v4.0_2.0.0.0__24c2f752a8e58a10\Serilog.Sinks.File.dll'

Compare that to the same line in my log:

DEBUG: Loaded 'Serilog.Sinks.File, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' from 'C:\Users\Robert 
Holt\Documents\Dev\Microsoft\PowerShellEditorServices\module\PowerShellEditorServices\bin\Common\Serilog.Sinks.File.dll'

Here's the method we depend on being there and here's where we call it.

It doesn't yet make sense to me though why an assembly with the same name, version and public token is failing like this, but it does seem somehow that the GAC assembly is missing that method.

I can tell you that this isn't an issue in PS 6 and 7, since they have much better mechanisms for dependency resolution.

@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

Ok our csproj specified Serilog.Sinkgs.File version 4.1.0, so something seems amiss here

@rjmholt
Copy link
Contributor

rjmholt commented Mar 10, 2020

serilog/serilog#1319 (comment)

The 2.0.0 assembly version seems to be very much by design...

@TylerLeonhardt
Copy link
Member

by design between 2.7 and 2.8... but we're on 4.1 now. Surely that should use an assembly version update

@mmascolino
Copy link

over on #2526 @rjmholt asked to repo with the preview extension so here it is:
1583874501-afcdef50-8118-4dc4-8e85-97bc2d5ea4661583874498632.zip

@rjmholt rjmholt changed the title Startup fails with: System.MissingMethodException: Method not found: Serilog.FileLoggerConfigurationExtensions.File Startup fails when incorrect Serilog assembly picked up from the GAC Mar 11, 2020
@SydneyhSmith SydneyhSmith added Area-Startup Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! labels Mar 12, 2020
@TylerLeonhardt
Copy link
Member

Can you all give the PowerShell Preview extension a try? We just did a release of it.

Don't forget to disable the regular PowerShell extension for VS Code when you enable the PowerShell Preview extension for VS Code

@clouditgirl
Copy link

@TylerLeonhardt
I installed PowerShell Preview extension and it didn't fix the issue with the error "ConsoleFeature>: Unable to instantiate; language client undefined."

vscode\extensions\ms-vscode.powershell-preview-2020.5.0\modules' -EnableConsoleRepl -StartupBanner "=====> PowerShell Preview Integrated Console v2020.5.0 <=====
" -LogLevel 'Normal' -LogPath 'c:\Users\Claudia.vscode\extensions\ms-vscode.powershell-preview-2020.5.0\logs\1589818401-0bc709be-f0e3-4621-82d1-203b9eaacb021589818395793\EditorServices.log' -SessionDetailsPath 'c:\Users\Claudia.vscode\extensions\ms-vscode.powershell-preview-2020.5.0\sessions\PSES-VSCode-2192-922253' -FeatureFlags @()
5/18/2020 12:13:21 PM [NORMAL] - pwsh.exe started.
5/18/2020 12:13:21 PM [NORMAL] - Waiting for session file
5/18/2020 12:13:28 PM [ERROR] - : Unable to instantiate; language client undefined.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label May 18, 2020
@TylerLeonhardt
Copy link
Member

What were you doing that caused ConsoleFeature>: Unable to instantiate; language client undefined.? Usually this is because the extension hasn't finished starting up.

@andyleejordan
Copy link
Member

The extension has gone through a major rewrite since this was originally reported and I've not seen the same bug report crop back up, so going ahead and marking this resolved. Thanks!

@andyleejordan andyleejordan added the Resolution-Inactive Will close automatically. label Jan 6, 2024
Copy link
Contributor

github-actions bot commented Jan 6, 2024

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added the Needs: Fix Verification Please verify the fix for us! label Jan 6, 2024
Copy link
Contributor

This issue has been labeled as needing fix verification and has not had any activity a week. It has been closed for housekeeping purposes.

@andyleejordan
Copy link
Member

The extension has gone through a major rewrite since this was originally reported and I've not seen the same bug report crop back up, so going ahead and marking this resolved. Thanks!

Joke's on me, this problem is still very much around and cropped up again after we updated Serilog.

Copy link
Contributor

This issue has been labeled as resolved, please verify the provided fix (or other reason).

@github-actions github-actions bot added Needs: Fix Verification Please verify the fix for us! and removed Needs: Maintainer Attention Maintainer attention needed! labels Nov 13, 2024
@JustinGrote JustinGrote removed Needs: Fix Verification Please verify the fix for us! Resolution-Inactive Will close automatically. labels Nov 13, 2024
@andyleejordan
Copy link
Member

andyleejordan commented Nov 15, 2024

The fix for this is merged, it will be in the next pre-release (coming out today). PowerShell/PowerShellEditorServices#2197

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

8 participants