Hi Podavu Mani Shankar Reddy,
Adding few more additional details to the answer provided by Chen1018,
The error "TreasuryBot.dialog error: Type Microsoft.CluRecognizer not registered in factory" is a common issue encountered when migrating a Bot Framework application from LUIS to CLU. This error means the CLU recognizer type (Microsoft.CluRecognizer) is not registered in your bot and cannot find the necessary instructions to create an instance of the CLURecognizer.
Adding the Using statement alone isn’t enough — the runtime must have the correct NuGet package installed and the component explicitly registered before your dialogs are loaded.
Here are a series of steps to troubleshoot the issue:
Step 1: Ensure that the correct NuGet package is installed in your project. This package contains the CLURecognizer class and its dependencies.
dotnet add package Microsoft.Bot.Components.Recognizers.CLURecognizer
In Visual Studio, go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution and search for the package. If it's not installed in your bot project, install it.
For more information click here: NuGet Gallery | Microsoft.Bot.Components.Recognizers.CLURecognizer 1.0.1
Step 2: Create the Registration Class and then register the Component in Program.cs
Create a class that inherits from BotComponent. This class is a self-contained unit that tells the application's dependency injection container which services to add.
File: CLURecognizerRegistration.cs
C#
using Microsoft.Bot.Builder;
using Microsoft.Bot.Components.Recognizers.CLURecognizer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
public class CLURecognizerRegistration : BotComponent
{
public override void ConfigureServices(
IServiceCollection services,
IConfiguration configuration)
{
// Register the CLURecognizer as a singleton.
services.AddSingleton<CLURecognizer>();
}
}
File: Program.cs
C#
// Import the necessary namespaces
using Microsoft.Bot.Builder;
// Create the application builder
var builder = WebApplication.CreateBuilder(args);
// Register your custom BotComponent
// tells the dependency injection container to recognize your registration class and call its ConfigureServices method.
builder.Services.AddSingleton<BotComponent, CLURecognizerRegistration>();
// ... [other service registrations and middleware configuration]
var app = builder.Build();
app.Run();
Step 3: After registering the component, ensure that the application's configuration and dialog files are correctly set up for CLU.
appsettings.json: Confirm that you have the necessary CLU configuration keys and that their values match your Azure Language Service resource.
JSON
{
"CluProjectName": "YourCluProjectName",
"CluDeploymentName": "YourCluDeploymentName",
"CluAPIKey": "YourCluAPIKey",
"CluAPIHostName": "https://<your-language-resource-name>.cognitiveservices.azure.com"
}
If you are using Adaptive Dialogs with dialog files, verify that the $kind property for your recognizer is correctly specified as "Microsoft.CluRecognizer".
After publishing, confirm Microsoft.Bot.Components.Recognizers.CLURecognizer.dll is present in the output folder. Missing DLLs will also trigger this error.
If the package is installed, registration code is added, and $kind is correct, you will correctly register the CLURecognizer with the dependency injection system, allowing your bot to instantiate the component and successfully migrate to Conversational Language Understanding.
Follow the above steps to troubleshoot the issue. For any additional help or assistance do let me know. I am happy to help you with your queries.
If the information is helpful, please click on Upvote and Accept Answer on it so that it can help other community members.
Thank you,
Rashmika