oraios/serena · error · SolidLSPException

Failed to start C# language server

Error message

Failed to start C# language server: {e}

What it means

Raised by _start_server when self.server.start() throws any exception while launching the Roslyn language server process; it wraps the underlying error in SolidLSPException. Commonly the DLL can't be launched (missing runtime, wrong architecture) or the process dies immediately.

Solutions

  1. Check the logged inner message ('Failed to start language server process: {e}') for the root cause
  2. Install/upgrade the .NET SDK/runtime to a version compatible with the Roslyn language server
  3. Re-download the language server for the correct platform (clear cache dir and rerun)
  4. Verify the DLL/executable is runnable manually: `dotnet <server_dll> --help` or executing the native binary directly

Example fix

// before
$ dotnet --list-runtimes # (nothing installed)
// after
sudo apt-get install -y dotnet-sdk-9.0
$ dotnet --list-runtimes # Microsoft.NETCore.App 9.x
Defensive patterns

Strategy: validation

Validate before calling

import subprocess
from pathlib import Path

def can_launch_roslyn(server_dll: str) -> tuple[bool, str]:
    dll = Path(server_dll)
    if not dll.is_file():
        return False, "DLL missing"
    try:
        p = subprocess.run(["dotnet", "--list-runtimes"], capture_output=True, text=True, timeout=30)
    except (OSError, subprocess.TimeoutExpired):
        return False, ".NET runtime missing or not runnable"
    if p.returncode != 0 or "Microsoft.NETCore.App" not in p.stdout:
        return False, ".NET runtime not installed"
    return True, p.stdout.splitlines()[0]

Type guard

def dotnet_runtime_available() -> bool:
    import shutil
    return shutil.which("dotnet") is not None

Try / catch

try:
    ls._start_server()
except SolidLSPException as e:
    log.error(f"Roslyn start failed: {e}")
    ok, reason = can_launch_roslyn(server_dll)
    if not ok:
        install_dotnet_runtime()  # e.g. apt install dotnet-sdk-9.0
        ls._start_server()
    else:
        raise

Prevention

When it happens

Trigger: CSharpLanguageServer._start_server when LanguageServer.start() raises — e.g. the launch command can't execute (missing .NET runtime, bad DLL path), missing dependencies for the Roslyn server, or spawn permission errors.

Common situations: .NET runtime not installed or too old for the Roslyn server version, executable bit not set (permission), Apple Silicon running x64-only build without Rosetta, or the server binary downloaded for the wrong OS.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/536e5f56bf79e1c1. Report an issue: GitHub.

Appendix: source

Thrown at src/solidlsp/language_servers/csharp_language_server.py:663

            indexing_complete.set()

        # Set up notification handlers
        self.server.on_notification("window/logMessage", window_log_message)
        self.server.on_notification("$/progress", handle_progress)
        self.server.on_notification("textDocument/publishDiagnostics", do_nothing)
        self.server.on_notification("workspace/projectInitializationComplete", handle_workspace_indexing_complete)
        self.server.on_request("workspace/configuration", handle_workspace_configuration)
        self.server.on_request("window/workDoneProgress/create", handle_work_done_progress_create)
        self.server.on_request("client/registerCapability", handle_register_capability)
        self.server.on_request("workspace/_roslyn_projectNeedsRestore", handle_project_needs_restore)

        log.info("Starting Microsoft.CodeAnalysis.LanguageServer process")

        try:
            self.server.start()
        except Exception as e:
            log.info(f"Failed to start language server process: {e}", logging.ERROR)
            raise SolidLSPException(f"Failed to start C# language server: {e}")

        # Send initialization
        initialize_params = self._create_initialize_params()

        log.info("Sending initialize request to language server")
        try:
            init_response = self.server.send.initialize(initialize_params)
            log.info(f"Received initialize response: {init_response}")
        except Exception as e:
            raise SolidLSPException(f"Failed to initialize C# language server for {self.repository_root_path}: {e}") from e

        # Apply diagnostic capabilities
        self._force_pull_diagnostics(init_response)

        # Verify required capabilities
        capabilities = init_response.get("capabilities", {})
        required_capabilities = [
            "textDocumentSync",

View on GitHub (pinned to 7fcbca7e62)