Dependencies erroneously loaded from GAC first in Windows PowerShell
See original GitHub issueIssue Description
Powershell services appears to crash on launch with ‘Missing method exception:’
Exception calling "StartLogging" with "2" argument(s): "Method not found: 'Serilog.LoggerConfiguration Serilog.Configuration.LoggerSinkConfiguration.Wrap(Serilog.Configuration.LoggerSinkConfiguration, System.Func`2<Serilog.Core.ILogEventSink,Serilog.Core.ILogEventSink>, System.Action`1<Serilog.Configuration.LoggerSinkConfiguration>, Serilog.Events.LogEventLevel, Serilog.Core.LoggingLevelSwitch)'."
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()
at System.Management.Automation.CommandProcessorBase.Complete()
Method not found: 'Serilog.LoggerConfiguration Serilog.Configuration.LoggerSinkConfiguration.Wrap(Serilog.Configuration.LoggerSinkConfiguration, System.Func`2<Serilog.Core.ILogEventSink,Serilog.Core.ILogEventSink>, System.Action`1<Serilog.Configuration.LoggerSinkConfiguration>, Serilog.Events.LogEventLevel, Serilog.Core.LoggingLevelSwitch)'.
at Serilog.LoggerConfigurationAsyncExtensions.Async(LoggerSinkConfiguration loggerSinkConfiguration, Action`1 configure, IAsyncLogEventSinkMonitor monitor, Int32 bufferSize, Boolean blockWhenFull)
at Microsoft.PowerShell.EditorServices.Utility.Logging.Builder.Build()
at Microsoft.PowerShell.EditorServices.Host.EditorServicesHost.StartLogging(String logFilePath, LogLevel logLevel)
at CallSite.Target(Closure , CallSite , Object , Object , Object )
Attached Logs
Environment Information
Visual Studio Code
Name | Version |
---|---|
Operating System | Windows_NT x64 10.0.17763 |
VSCode | 1.36.1 |
PowerShell Extension Version | 2019.5.0 |
PowerShell Information
Name | Value |
---|---|
PSVersion | 5.1.17763.316 |
PSEdition | Desktop |
PSCompatibleVersions | 1.0 2.0 3.0 4.0 5.0 5.1.17763.316 |
BuildVersion | 10.0.17763.316 |
CLRVersion | 4.0.30319.42000 |
WSManStackVersion | 3.0 |
PSRemotingProtocolVersion | 2.3 |
SerializationVersion | 1.1.0.1 |
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
Extension | Author | Version |
---|---|---|
csharp | ms-vscode | 1.21.0 |
gitblame | waderyan | 2.8.1 |
powershell | ms-vscode | 2019.5.0 |
prettier-vscode | esbenp | 1.9.0 |
tslint | eg2 | 1.0.44 |
vscode-antlr4 | mike-lischke | 2.1.1 |
vsliveshare | ms-vsliveshare | 1.0.540 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Resolving PowerShell module assembly dependency conflicts
PowerShell always loads assemblies into the same context. This presents issues when a module's dependencies conflict with already-loaded ...
Read more >Basics: When does a .NET Assembly Dependency get loaded
Specifically ASP.NET pre-loads all assemblies referenced in the GAC assembly list and the /bin folder. So in Web applications it definitely pays ...
Read more >Telerik Web Forms Using the Global Assembly Cache
If you get the "Could not load file or assembly…" error. It means the reference is typed in wrongly or the assembly is...
Read more >c# - PowerShell: why am I able to load multiple versions of the ...
In your scenario, your modules are stand-alone .NET assemblies that implement PowerShell cmdlets. In both Windows PowerShell and PowerShell ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I know this is the older issue, but https://github.com/PowerShell/vscode-powershell/issues/2538 has some more pertinent discussion so I’ll deduplicate to that and pin that one.
Loading from the GAC first is a by-design behaviour in .NET Framework that we can’t work around and the issue is that Serilog’s assembly versioning is deliberately broken.
The solution for us is likely to remove Serilog.
Ah nice hunch! It’s a bug on our part then; we only add the types we immediately call into on startup and let them load their dependencies as they go. From this it sounds like that’s fragile and we should eagerly load everything (although in PS 6+ this isn’t a problem actually)