AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/samples/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

Sharing message assemblies

Component:
NServiceBus
NuGet Package:
NServiceBus 9.x

This sample shows how the NServiceBus.MessageInterfaces package can be used to create a shared message assembly that can be used by multiple major versions of NServiceBus, and in projects using different target frameworks, while still relying on the ICommand and IEvent marker interfaces.

In this sample, an NServiceBus endpoint running on .NET Framework can share a message assembly with another endpoint running a newer version of NServiceBus and .NET without the need to employ unobtrusive message conventions, which is especially useful for projects transitioning from .NET Framework to .NET that were not originally designed with message conventions in mind.

Shared project

The Shared project references the NServiceBus.MessageInterfaces, which contains the definitions for IMessage, ICommand, and IEvent. Because this project targets netstandard2.0 it can be used from both .NET and .NET Framework applications.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <LangVersion>12.0</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NServiceBus.MessageInterfaces" Version="1.*" />
  </ItemGroup>

</Project>

There is a single message type defined, MyCommand, which derives from ICommand.

Sending messages

The Sender endpoint uses NServiceBus 8.2 on .NET Framework and sends MyCommand messages to Receiver.

Receiving messages

The Receiver endpoint uses NServiceBus 9 on modern .NET and has a handler for MyCommand messages.

Related Articles