---
title: "Diagnose replay module loading failures"
url: https://recursiveai.org/onescope/cookbook/list-replay-module-load-errors/
description: "Diagnose failed OneScope replay module loads from the command line. Read the JSON error code and distinguish a missing DLL from an unusable module."
version: "1.0.0"
---

# Diagnose replay module loading failures

**OneScope** is a free, open-source viewer for simulation recordings, with a desktop window or command-line control, from Recursive AI. MIT or Apache-2.0.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneScope.Tool) · [GitHub](https://github.com/recursive-ai-oss/onescope-csharp) · [Docs](https://recursiveai.org/onescope/docs/) · [Download example (.zip)](https://recursiveai.org/onescope/cookbook/list-replay-module-load-errors/list-replay-module-load-errors.zip)

Read the JSON error from `onescope open` to find out why a replay reader DLL didn’t load. A module is a DLL you write that teaches OneScope to read your recording format. Headless mode still needs a graphics driver.

```shell
dotnet tool install -g RecursiveAI.OneScope.Tool
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

Use `counter.sim` from the example zip.

```shell
onescope open counter.sim --headless --module MissingModule.dll
```

[The example](https://recursiveai.org/onescope/cookbook/list-replay-module-load-errors/list-replay-module-load-errors.zip) is the full program below: unzip it and `dotnet run`.

The command exits with code `1` and prints this JSON (formatted here for readability):

```json
{
  "ok": false,
  "error": {
    "code": "not_found",
    "message": "Module assembly 'MissingModule.dll' does not exist; expected a .dll built against RecursiveAI.OneScope.Sdk."
  }
}
```

## The full program

The zip’s sample `counter.sim` contains the single line `COUNT 3`. Neither failure reaches the replay bytes: the shell checks the module first. The program installs the pinned tool into its own `obj` folder and checks a missing DLL and a DLL that has no module.

```csharp
using System.Diagnostics;
using System.Text.Json;

string tools = Path.GetFullPath("obj/tools");
string tool = Path.Combine(tools,
    OperatingSystem.IsWindows() ? "onescope.exe" : "onescope");
if (!File.Exists(tool))
{
    var install = Run("dotnet", "tool", "install", "RecursiveAI.OneScope.Tool",
        "--tool-path", tools, "--version", "1.0.0");
    if (install.ExitCode != 0)
        throw new InvalidOperationException(install.Output);
}

// A missing DLL, then a valid .NET DLL with no OneScope module.
Diagnose("MissingModule.dll");
Diagnose(Path.GetRelativePath(Environment.CurrentDirectory,
    typeof(Program).Assembly.Location));

void Diagnose(string assembly)
{
    var run = Run(tool, "open", "counter.sim", "--headless", "--module", assembly);
    using var json = JsonDocument.Parse(run.Output);
    var error = json.RootElement.GetProperty("error");
    Console.WriteLine($"Exit {run.ExitCode}: {error.GetProperty("code").GetString()}");
    Console.WriteLine(error.GetProperty("message").GetString());
}

static (int ExitCode, string Output) Run(string command, params string[] args)
{
    var start = new ProcessStartInfo(command) { RedirectStandardOutput = true };
    foreach (string arg in args) start.ArgumentList.Add(arg);
    using var process = Process.Start(start)!;
    string output = process.StandardOutput.ReadToEnd();
    process.WaitForExit();
    return (process.ExitCode, output);
}
```

```text
Exit 1: not_found
Module assembly 'MissingModule.dll' does not exist; expected a .dll built against RecursiveAI.OneScope.Sdk.
Exit 1: bad_module
Module assembly 'bin/Debug/net10.0/Example.dll' has no public class that implements IScopeModule and can be created without arguments (a constructor whose parameters all have defaults is fine).
```

If the JSON names the replay file instead of the assembly, check the replay path: `not_found` is used for both.

## Related recipes

- [Load a custom replay module DLL](https://recursiveai.org/onescope/cookbook/load-custom-replay-module-from-dll/)
- [Detect an invalid replay file](https://recursiveai.org/onescope/cookbook/detect-invalid-replay-recording/)

## The short answer

Pass the reader DLL with `--module` and read `error.code` and `error.message` in the JSON response. A missing DLL gives `not_found`; a DLL that can’t be used as a module gives `bad_module`. For these failures, exit code `1` tells a script that the open failed, while the message identifies what to fix. If you pass `--module` more than once, a load failure stops the startup loop; it doesn’t return a list of errors for every DLL. Try one assembly at a time to isolate the problem.

## What does “failed to load” mean for a replay module?

Separate loading the DLL from opening the replay. First, the tool loads the assembly and looks for a concrete implementation of `IScopeModule` it can construct. A missing file, a file that isn’t a .NET assembly, or an assembly without a usable module can fail here. The example’s console DLL is a valid .NET assembly; it still receives `bad_module` because it doesn’t implement the reader contract.

Once the DLL has loaded, OneScope offers the file to the registered readers. If no reader accepts those bytes, check the recording format and the module that owns it rather than treating it as a DLL load error. Live attachment has a separate `no_module` error when the stream names a module the shell has not loaded.

## How do I tell why a module DLL won’t load?

Read the message that comes with `bad_module`. If it says the types couldn’t load, the loader includes a dependency or type-loading message when available. Check the module’s build output and resolve that error before changing the replay. If it says there’s no usable module class, check that your public implementation of `IScopeModule` has a public parameterless constructor, or a public constructor whose parameters all have defaults. Point `--module` at the reader assembly itself, not the shared SDK DLL or a project file.

For a missing DLL, resolve the path from the directory where you invoke `onescope`, or pass its absolute path. Fix that first and rerun the same command. That lets you distinguish the original path failure from any problem the loader encounters after it finds the file.
