Skip to main content

Fixed: CS0534 'CountWordsExecutor' does not implement inherited abstract member 'Executor.ConfigureProtocol(ProtocolBuilder)'

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

I wrote two class-based executors for a Microsoft Agent Framework workflow, added the workflows package, and dotnet run stopped with error CS0534: 'CountWordsExecutor' does not implement inherited abstract member 'Executor.ConfigureProtocol(ProtocolBuilder)', once for each class. The classes were fine. The project was missing Microsoft.Agents.AI.Workflows.Generators, the package whose source generator writes that method.

What I Was Doing​

I was building WordCount, a small console app with a two-step workflow. CleanText takes a text and removes its extra spaces, and CountWords counts the words that are left. Both steps are class-based executors, written the way Microsoft's documentation recommends: a partial class that derives from Executor, with one method marked [MessageHandler].

I created the app and added Agent Framework's workflows package:

Terminal
dotnet new console -o WordCount
cd WordCount
dotnet add package Microsoft.Agents.AI.Workflows --version 1.28.0

That gave this project file:

WordCount.csproj (as it was)
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Workflows" Version="1.28.0" />
</ItemGroup>

</Project>

Then I replaced everything in Program.cs with the workflow and its two executors:

Program.cs
using Microsoft.Agents.AI.Workflows;

CleanTextExecutor cleanText = new();
CountWordsExecutor countWords = new();

Workflow workflow = new WorkflowBuilder(cleanText)
.AddEdge(cleanText, countWords)
.WithOutputFrom(countWords)
.Build();

await using Run run = await InProcessExecution.RunAsync(workflow, " the quick brown fox ");

foreach (WorkflowEvent workflowEvent in run.OutgoingEvents)
{
switch (workflowEvent)
{
case ExecutorCompletedEvent completed:
Console.WriteLine($"{completed.ExecutorId} returned: {completed.Data}");
break;
case WorkflowOutputEvent output:
Console.WriteLine($"The workflow's output: {output.Data}");
break;
}
}

// Step 1: takes a text and returns it without its extra spaces.
internal sealed partial class CleanTextExecutor() : Executor("CleanText")
{
[MessageHandler]
private string Handle(string text, IWorkflowContext context) =>
string.Join(' ', text.Split(' ', StringSplitOptions.RemoveEmptyEntries));
}

// Step 2: takes a clean text and returns how many words it has.
internal sealed partial class CountWordsExecutor() : Executor("CountWords")
{
[MessageHandler]
private int Handle(string text, IWorkflowContext context) => text.Split(' ').Length;
}

What I Expected​

Each executor's result and the workflow's output: the text without its extra spaces, then 4, the number of words in it.

What I Got​

Terminal
dotnet run
Output
/Users/you/source/WordCount/Program.cs(35,31): error CS0534: 'CountWordsExecutor' does not implement inherited abstract member 'Executor.ConfigureProtocol(ProtocolBuilder)'
/Users/you/source/WordCount/Program.cs(27,31): error CS0534: 'CleanTextExecutor' does not implement inherited abstract member 'Executor.ConfigureProtocol(ProtocolBuilder)'

The build failed. Fix the build errors and run again.

macOS-style window with two panes. Above, WordCount.csproj with a single package reference, Microsoft.Agents.AI.Workflows version 1.28.0. Below, dotnet run failing with error CS0534 twice, because CountWordsExecutor and CleanTextExecutor do not implement the inherited abstract member Executor.ConfigureProtocol(ProtocolBuilder), followed by The build failed.

The build failed, so the app never ran.

What I Checked​

Where the errors point. Program.cs(35,31) is line 35, column 31: the name CountWordsExecutor in its class declaration. Program.cs(27,31) is the same spot in CleanTextExecutor's declaration. The compiler wasn't pointing at a line inside either class, but at each class as a whole.

What CS0534 means. Microsoft's reference for the error: A class is required to implement all the abstract members in the base class, unless the class is also abstract. The base class here is Executor, so Executor has an abstract method, ConfigureProtocol(ProtocolBuilder), that neither of my classes implemented.

What that method does. Its summary in the 1.28.0 package documentation: Configures the protocol by setting up routes and declaring the message types used for sending and yielding output. In other words, it tells the workflow which messages the executor accepts and what it sends on. My classes didn't have it, and neither do the class-based executors in Microsoft's documentation: they only mark a method with [MessageHandler], as mine did.

What is supposed to write it. The summary of MessageHandlerAttribute in the same documentation: Marks a method as a message handler for source-generated route configuration. Microsoft's Executors guide says the attribute uses compile-time source generation for handler registration, providing better performance, compile-time validation, and Native AOT compatibility. A source generator is a tool that runs while the project compiles and adds code to it. So the route configuration, ConfigureProtocol, comes from a generator, not from me.

Which package holds the generator. The install step of Microsoft's conditional-edges tutorial adds Microsoft.Agents.AI.Workflows.Generators next to Microsoft.Agents.AI.Workflows, with this note: Source generator packages don't flow transitively, so reference it directly in the project that defines the executors. The package's own description: Provides Roslyn source generators for Microsoft Agent Framework Workflows, enabling compile-time route configuration for executors. My project referenced only the workflows package, so no generator ran.

Why It Happens​

Executor declares ConfigureProtocol as abstract, so every class that derives from it needs an implementation. With class-based executors you don't write that implementation yourself: the generator in Microsoft.Agents.AI.Workflows.Generators reads the partial classes with [MessageHandler] methods while the project compiles, and adds the missing part. Without the package, nothing adds it, and the compiler reports CS0534 once for each executor class.

The Fix​

Add the generator package to the project that defines the executors:

Terminal
dotnet add package Microsoft.Agents.AI.Workflows.Generators --version 1.28.0
Output
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/local/share/dotnet/sdk/10.0.404/trustedroots/codesignctl.pem'.
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/local/share/dotnet/sdk/10.0.404/trustedroots/timestampctl.pem'.
info : Adding PackageReference for package 'Microsoft.Agents.AI.Workflows.Generators' into project '/Users/you/source/WordCount/WordCount.csproj'.
info : Restoring packages for /Users/you/source/WordCount/WordCount.csproj...
info : CACHE https://api.nuget.org/v3/vulnerabilities/index.json
info : CACHE https://api.nuget.org/v3-vulnerabilities/2026.11.20.05.34.20/vulnerability.base.json
info : CACHE https://api.nuget.org/v3-vulnerabilities/2026.11.20.05.34.20/2026.11.30.11.35.26/vulnerability.update.json
info : Package 'Microsoft.Agents.AI.Workflows.Generators' is compatible with all the specified frameworks in project '/Users/you/source/WordCount/WordCount.csproj'.
info : PackageReference for package 'Microsoft.Agents.AI.Workflows.Generators' version '1.28.0' added to file '/Users/you/source/WordCount/WordCount.csproj'.
info : Writing assets file to disk. Path: /Users/you/source/WordCount/obj/project.assets.json
log : Restored /Users/you/source/WordCount/WordCount.csproj (in 732 ms).

The project file now references both packages:

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

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Workflows" Version="1.28.0" />
<PackageReference Include="Microsoft.Agents.AI.Workflows.Generators" Version="1.28.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>

The generator's reference looks different from the first one because the package marks itself as a development dependency: its metadata has <developmentDependency>true</developmentDependency>. So dotnet add package wrote two extra settings:

  • PrivateAssets set to all. NuGet's documentation says these assets will be consumed but won't flow to the parent project. The generator works for this project and isn't passed on to projects that reference it.
  • IncludeAssets without compile. For a development dependency, NuGet will exclude compile-time assets from compilation. The list keeps analyzers, where the generator lives.

That's also why each project that defines executors needs its own reference to the package.

After the Fix​

I didn't change a line of Program.cs:

Terminal
dotnet run
Output
CleanText returned: the quick brown fox
CountWords returned: 4
The workflow's output: 4

macOS-style window with two panes. Above, WordCount.csproj with two package references, Microsoft.Agents.AI.Workflows and Microsoft.Agents.AI.Workflows.Generators, both version 1.28.0, the second with IncludeAssets and PrivateAssets all. Below, dotnet run printing CleanText returned: the quick brown fox, CountWords returned: 4, and The workflow's output: 4.

Both classes now build as they are, because the generator supplied what CS0534 said was missing. CleanText removed the extra spaces, CountWords counted four words, and its count is the workflow's output.

Common Mistakes​

MistakeWhat happensDo this instead
Adding only Microsoft.Agents.AI.WorkflowsCS0534 for every class-based executorAdd Microsoft.Agents.AI.Workflows.Generators as well
Referencing the generator from a different project onlySource generator packages don't flow transitively, so the project that defines the executors still has noneReference it in the project that defines the executors
Declaring an executor class without partialMAFGENWF003, plus CS0534 for that class (Fixed)Mark every executor class partial

Troubleshooting​

SymptomLikely causeFix
CS0534 for ConfigureProtocol on every executor classThe generator package is missing from the projectAdd Microsoft.Agents.AI.Workflows.Generators
CS0534 on one class only, next to MAFGENWF003That class isn't partialAdd partial to its declaration

FAQ​

Do I need the generator in every project?​

In every project that defines executors with [MessageHandler] methods. Microsoft's note is direct about it: reference the package in the project that defines the executors, because source generator packages don't flow transitively.

Why must the class be partial?​

A partial class is written in parts that the compiler joins into one class. Microsoft's C# guide lists source generators as one reason to split a class: Source generators can generate extra functionality in a class. The generator adds its code as one more part of your class, and the guide's rule for parts is strict: All the parts must use the partial keyword. A class without partial gets error MAFGENWF003 (Fixed).

Conclusion​

CS0534: 'CountWordsExecutor' does not implement inherited abstract member 'Executor.ConfigureProtocol(ProtocolBuilder)' on a class-based executor means the workflows source generator isn't in the project, so nothing writes the method that registers your [MessageHandler] methods. Add Microsoft.Agents.AI.Workflows.Generators to the project that defines the executors, keep each executor class partial, and the same code builds and runs.

Additional Resources​