-
Notifications
You must be signed in to change notification settings - Fork 234
Simplify inherited IDisposable
logic due to Serilog
#1477
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
Comments
When I run Start-EditorServices from my application, I get the following error:
I’ve added the same 4 Serilog Nuget packages, including serilog.extensions.logging and it still happens. The only workaround is to add the PowerShellEditorServices csproj to my Solution, and then add it as a Project Reference. If I add it to my solution but don’t add it as a project reference, the error occurs. For context, this has been happening for at least a year, but I forgot about it until this week when changes were made which should allow me to use the production build of PSES. I don’t know if the proposed changes here would solve my issue, but I didn’t want to make a new issue when there was already one discussing Serilog. |
Thank you, at least I'm not crazy or the only one with this issue. Serilog is not in my GAC but it is being used in the calling application. I suspect that is the issue. |
Perhaps we should prioritize dumping Serilog 🤔 |
I probably could have removed it in less time than I've spent debugging this. |
Interestingly enough, somebody just put a Pull Request into Serilog.Extensions.Logging an hour ago that may address this issue. What if the problem is that this particular interface doesn't get exposed when called from a parent process running an incompatible .net core version, in my case .net 5.0 |
I removed all references to Serilog and am now getting
Digging deeper, I think the overall problem might be the version of Serilog and Microsoft.Extensions.Logging that Omnisharp is using: |
Hm very interesting, especially since we apparently use vastly different versions: PowerShellEditorServices/src/PowerShellEditorServices/PowerShellEditorServices.csproj Line 31 in da481f2
PowerShellEditorServices/src/PowerShellEditorServices/PowerShellEditorServices.csproj Line 36 in da481f2
|
I would 💯accept a PR replacing Serilog @dkattan, looking into it myself. |
Open to helping resolve this if it turns out to be worthwhile - a bit swamped on the Serilog side of things, so would need some tactical PRs that don't introduce a huge amount of churn (which makes the one @dkattan linked above a bit tricky to move forward with in a hurry). Unfortunately, with Serilog right down the bottom of the dependency graph, this stuff is never fun :-) ... good luck, either way! 👍 |
I got it to work! I added the following NuGet packages to my application
Then deleted everything in module\PowerShellEditorServices\bin\Common except Microsoft.PowerShell.EditorServices.dll and magically everything worked. I believe the problem here to be here We aren't checking the loaded assemblies to verify that we actually need to load the files before loading them. The tip off was me watching the ordering of the loaded assemblies when it worked versus when it didn't. When it worked it loaded in this order
When it didn't
It wasn't that it was loading the incorrect version, the versions were identical, I think it has to do with my calling context having already loaded Serilog and a variety of other assemblies, and PSES attempting to load them again. I think if I modify the aforementioned code to check if the assembly is already loaded before calling LoadFromAssemblyPath, we'll be good. |
Serilog is now gone! I think we left the classes as |
Noted in #1474, a bunch of our factories used to abstract our logging setup during initialization are
IDisposable
and so have to call each other'sDispose()
methods, all due to the fact that we need to callSerilog.Log.CloseAndFlush()
at the end of the program. This is actually a place where referencing a global is perhaps a better pattern, since the logger is already global, but Serilog provides an even better option by passing the parameterdispose=true
when usingSerilogLoggerFactoryExtensions.AddSerilog(dispose=true)
.The text was updated successfully, but these errors were encountered: