Omnisharp fails to open all Unity projects. No export was found for the contract 'ILoggerFactory'
Issue Description
For no apparent reason, OmniSharp has started crashing on VS Code startup.
Steps to Reproduce
Open VSCode
Expected Behavior
OmniSharp starts up.
Actual Behavior
OmniSharp crashes.
Logs
OmniSharp log
Starting OmniSharp server at 12/22/2022, 9:59:53 PM
Target: /home/ben/bwbots-beer-caddy/unity/BWBots ROS1 Simulator/BWBots ROS1 Simulator.sln
OmniSharp server started with Mono 6.12.0 (/usr/bin/mono).
Path: /home/ben/.vscode/extensions/ms-dotnettools.csharp-1.25.2-linux-x64/.omnisharp/1.39.3-beta.24/omnisharp/OmniSharp.exe
PID: 7422
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Cake, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.DotNetTest, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Host, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.MSBuild, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn.CSharp, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Script, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Shared, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on ubuntu 20.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[dbug]: OmniSharp.CompositionHostBuilder
.NET SDK requires MSBuild instances version 16.8.0 or higher
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: Mono 16.10.1 - "/usr/lib/mono/msbuild/Current/bin"
[dbug]: OmniSharp.CompositionHostBuilder
MSBuild instance Mono 16.10.1 scored at 2
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Mono 16.10.1 - "/usr/lib/mono/msbuild/Current/bin"
[STDERR] System.Composition.Hosting.CompositionFailedException: No export was found for the contract 'ILoggerFactory'
-> required by import 'loggerFactory' of part 'DefaultProjectChangePublisher'
-> required by import 'projectConfigurationPublisher' of part 'MSBuildProjectManager'
-> required by import 'item' of part 'IMSBuildEventSink[]'
-> required by import 'eventSinks' of part 'ProjectSystem'
-> required by import 'item' of part 'IProjectSystem[]'
-> required by initial request for contract 'IProjectSystem[] { IsImportMany = True }'
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckTarget (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x00037] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckDependency (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x000cb] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckTarget (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x00076] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckDependency (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x000cb] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckTarget (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x00076] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckDependency (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x000cb] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckTarget (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x00076] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckDependency (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x000cb] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckTarget (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x00076] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckDependency (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x000cb] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.CheckTarget (System.Composition.Hosting.Core.CompositionDependency dependency, System.Collections.Generic.HashSet`1[T] checked, System.Collections.Generic.Stack`1[T] checking) [0x00076] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistryUpdate.Execute (System.Composition.Hosting.Core.CompositionContract contract) [0x00030] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.ExportDescriptorRegistry.TryGetSingleForExport (System.Composition.Hosting.Core.CompositionContract exportKey, System.Composition.Hosting.Core.ExportDescriptor& defaultForExport) [0x0004f] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.LifetimeContext.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x00000] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.CompositionHost.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x00000] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.CompositionContext.GetExport (System.Composition.Hosting.Core.CompositionContract contract) [0x00000] in <9222e906419e4f47bc57ced5ad91678c>:0
at System.Composition.CompositionContext.GetExports (System.Type exportType, System.String contractName) [0x00023] in <9222e906419e4f47bc57ced5ad91678c>:0
at System.Composition.CompositionContext.GetExports[TExport] (System.String contractName) [0x00000] in <9222e906419e4f47bc57ced5ad91678c>:0
at System.Composition.CompositionContext.GetExports[TExport] () [0x00000] in <9222e906419e4f47bc57ced5ad91678c>:0
at OmniSharp.Stdio.Host.Initialize () [0x0001e] in <e97ae9c8a1e74a549d799b7a017daa19>:0
at OmniSharp.Stdio.Host..ctor (System.IO.TextReader input, OmniSharp.Services.ISharedTextWriter writer, OmniSharp.IOmniSharpEnvironment environment, System.IServiceProvider serviceProvider, OmniSharp.CompositionHostBuilder compositionHostBuilder, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Threading.CancellationTokenSource cancellationTokenSource) [0x0007b] in <e97ae9c8a1e74a549d799b7a017daa19>:0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x0017d] in <96f323e5175244baa24aa0c2054fcfb9>:0
at OmniSharp.CommandLineApplication+<>c__DisplayClass12_0.<OnExecute>b__0 () [0x0000b] in <98a6c62bc85e480eaeba8e1cc4347cca>:0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication+<>c__DisplayClass146_0.<OnExecute>b__0 (System.Threading.CancellationToken _) [0x00000] in <abe0fc6797a94a73931eea5cecaffd78>:0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync (System.String[] args, System.Threading.CancellationToken cancellationToken) [0x000bf] in <abe0fc6797a94a73931eea5cecaffd78>:0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00016] in <abe0fc6797a94a73931eea5cecaffd78>:0
at OmniSharp.CommandLineApplication.Execute (System.String[] args) [0x00081] in <98a6c62bc85e480eaeba8e1cc4347cca>:0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <96f323e5175244baa24aa0c2054fcfb9>:0
at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <98a6c62bc85e480eaeba8e1cc4347cca>:0
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).
Environment information
VSCode version: 1.74.2 C# Extension: 1.25.2
Mono Information
OmniSharp using mono: 6.12.0Dotnet Information
Found dotnet version 5.0.408. Minimum required version is 6.0.100.Visual Studio Code Extensions
| Extension | Author | Version |
|---|---|---|
| autodocstring | njpwerner | 0.6.1 |
| CamelCase | MarioQueiros | 1.0.5 |
| cmake-language-support-vscode | josetr | 0.0.7 |
| cpptools | ms-vscode | 1.13.8 |
| cpptools-extension-pack | ms-vscode | 1.3.0 |
| cpptools-themes | ms-vscode | 2.0.0 |
| csharp | ms-dotnettools | 1.25.2 |
| gitlens | eamodio | 13.2.0 |
| intellicode-api-usage-examples | VisualStudioExptTeam | 0.2.6 |
| isort | ms-python | 2022.8.0 |
| java | redhat | 1.13.0 |
| jupyter | ms-toolsai | 2022.11.1003412109 |
| jupyter-keymap | ms-toolsai | 1.0.0 |
| jupyter-renderers | ms-toolsai | 1.0.12 |
| python | ms-python | 2022.20.1 |
| python-environment-manager | donjayamanne | 1.0.4 |
| remote-containers | ms-vscode-remote | 0.266.1 |
| vsc-python-indent | KevinRose | 1.18.0 |
| vscode-commons | redhat | 0.0.6 |
| vscode-docker | ms-azuretools | 1.23.3 |
| vscode-dotnet-runtime | ms-dotnettools | 1.6.0 |
| vscode-java-debug | vscjava | 0.47.0 |
| vscode-java-dependency | vscjava | 0.21.1 |
| vscode-java-pack | vscjava | 0.25.7 |
| vscode-java-test | vscjava | 0.37.1 |
| vscode-jupyter-cell-tags | ms-toolsai | 0.1.6 |
| vscode-jupyter-slideshow | ms-toolsai | 0.1.5 |
| vscode-maven | vscjava | 0.40.2 |
| vscode-pbtxt | thesofakillers | 0.0.4 |
| vscode-pylance | ms-python | 2022.12.20 |
| vscode-ros | ms-iot | 0.8.4 |
| vscode-wpilib | wpilibsuite | 2022.2.1 |
| vscode-xml | redhat | 0.23.0 |
| vsliveshare | ms-vsliveshare | 1.0.5788 |
Same issue happens with dotnet 6.0.4 is installed
Setting omnisharp.path to latest would break.
Setting omnisharp.path to empty string could fix.
That was it! Thanks.
Or just remove it altogether, work in my case
Should this issue be kept open? Because setting that to latest should not cause any problem
setting omnisharp.path to empty string fixed this issue for me too.
Why was this issue closed? Changing omnisharp.path is only a workaround. The issue actually needs to be fixed.
This issue should not be closed. Temporary fix doesn't work for me, and root cause it still unidentified.

@nateonline I had the same issue - The solution here https://github.com/microsoft/vscode/issues/170031 worked for me.
This issue should not be closed. Temporary fix doesn't work for me, and root cause it still unidentified.
@nateonline
Note that you should be setting "Omnisharp: Path", not "Omnisharp: Dotnet Path".
