Skip to content

Elsa 3.6-rc 2 Agent Persestnent Error #118

@fshahin90

Description

@fshahin90

.Net Runtime: 10.0
Elsa Version: 3.6.0-RC2


I tried to implement the following example using Elsa 3.6.0-rc2 but when i run the program i get the following error:
Unhandled exception. System.TypeLoadException: Could not load type 'Elsa.Agents.Persistence.Contracts.IApiKeyStore' from assembly 'Elsa.Agents.Persistence, Version=3.6.0.0, Culture=neutral, PublicKeyToken=null'

I guess the problem is that the Elsa.Agents.Persistence.EntityFrameworkCore.SqlServer doesnt have a 3.6.0-rc2 package in the nuget store though i tried to install the latest from the preview repository with the same result

below some outputs i out form the system

Terminal output

dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
dotnet watch 💡 Press Ctrl+R to restart.
dotnet watch 🔨 Building D:\test\Elsa\Server\Server.csproj ...
dotnet watch 🔨 Build succeeded: D:\test\Elsa\Server\Server.csproj
Using launch settings from D:\test\Elsa\Server\Properties\launchSettings.json...
Unhandled exception. System.TypeLoadException: Could not load type 'Elsa.Agents.Persistence.Contracts.IApiKeyStore' from assembly 'Elsa.Agents.Persistence, Version=3.6.0.0, Culture=neutral, PublicKeyToken=null'.
   at Elsa.Agents.Persistence.EntityFrameworkCore.EFCoreAgentPersistenceFeature.<>c.<Configure>b__1_0(AgentPersistenceFeature feature)
   at Elsa.Agents.Persistence.EntityFrameworkCore.EFCoreAgentPersistenceFeature.<>c.<Configure>b__1_0(AgentPersistenceFeature feature)
   at Elsa.Features.Implementations.Module.Configure[T](Func`2 factory, Action`1 configure)
   at Elsa.Features.Implementations.Module.Configure[T](Action`1 configure)
   at Elsa.Agents.Persistence.EntityFrameworkCore.EFCoreAgentPersistenceFeature.Configure()
   at Elsa.Features.Implementations.Module.ConfigureFeature(IFeature feature)
   at Elsa.Features.Implementations.Module.Configure[T](Func`2 factory, Action`1 configure)
   at Elsa.Features.Implementations.Module.Configure[T](Action`1 configure)
   at Elsa.Agents.Extensions.UseEntityFrameworkCore(AgentPersistenceFeature feature, Action`1 configure)
   at Program.<>c__DisplayClass0_0.<<Main>$>b__8(AgentPersistenceFeature ea) in D:\test\Elsa\Server\Program.cs:line 57
   at Elsa.Features.Implementations.Module.Configure[T](Func`2 factory, Action`1 configure)
   at Elsa.Features.Implementations.Module.Configure[T](Action`1 configure)
   at Elsa.Extensions.DependencyInjectionExtensions.Use[T](IModule module, Action`1 configure)
   at Elsa.Extensions.ModuleExtensions.UseAgentPersistence(IModule module, Action`1 configure)
   at Program.<>c__DisplayClass0_0.<<Main>$>b__0(IModule elsa) in D:\test\Elsa\Server\Program.cs:line 55
   at Elsa.Features.AppFeature.Configure()
   at Elsa.Features.Implementations.Module.ConfigureFeature(IFeature feature)
   at Elsa.Features.Implementations.Module.Apply()
   at Elsa.Extensions.ModuleExtensions.AddElsa(IServiceCollection services, Action`1 configure)
   at Program.<Main>$(String[] args) in D:\test\Elsa\Server\Program.cs:line 15
dotnet watch ❌ [Server (net10.0)] Exited with error code -532462766
dotnet watch ⏳ Waiting for a file to change before restarting ...

Packages

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

  <ItemGroup>
    <ProjectReference Include="..\UI\UI.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Elsa" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Agents.Activities" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Agents.Api" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Agents.Core" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Agents.Persistence" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Agents.Persistence.EFCore" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Agents.Persistence.EntityFrameworkCore.SqlServer" Version="3.3.5" />
    <PackageReference Include="Elsa.CSharp" Version="3.5.3" />
    <PackageReference Include="Elsa.EntityFrameworkCore" Version="3.5.3" />
    <PackageReference Include="Elsa.EntityFrameworkCore.SqlServer" Version="3.5.3" />
    <PackageReference Include="Elsa.Http" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Identity" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Scheduling" Version="3.6.0-rc2" />
    <PackageReference Include="Elsa.Workflows.Api" Version="3.6.0-rc2" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.2" />
  </ItemGroup>

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

</Project>

Program.cs

using Elsa.Agents;
using Elsa.EntityFrameworkCore.Extensions;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.Extensions;
using FastEndpoints.Swagger;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets();

var services = builder.Services;
var configuration = builder.Configuration;

services.AddElsa(elsa =>
{
    elsa.UseWorkflowManagement(management =>
    {
        management.UseEntityFrameworkCore(mef =>
        {
            mef.UseSqlServer(configuration.GetConnectionString("Default")!, new Elsa.EntityFrameworkCore.ElsaDbContextOptions()
            {
                SchemaName = "ElsaMGMT"
            });
        });
    });
    elsa.UseWorkflowRuntime(runtime =>
    {
        runtime.UseEntityFrameworkCore(rtef =>
        {
            rtef.UseSqlServer(configuration.GetConnectionString("Default")!, new Elsa.EntityFrameworkCore.ElsaDbContextOptions()
            {
               SchemaName = "ElsaRT" 
            });
        });
    });
    elsa.UseIdentity(identity =>
    {
        identity.TokenOptions = options=> options.SigningKey = "88550a502ac54615bdcafa8ae84ee1fe";
        identity.UseAdminUserProvider();
    });
    elsa.AddFastEndpointsFromModule();
    elsa.UseWorkflowsApi();
    elsa.UseDefaultAuthentication(auth=>auth.UseAdminApiKey());
    elsa.UseScheduling();
    elsa.UseJavaScript();
    elsa.UseLiquid();
    elsa.UseCSharp();
    elsa.UseHttp(http =>
    {
        http.ConfigureHttpOptions = options=>configuration.GetSection("Http").Bind(options);
    });
    
    elsa.UseAgentActivities();
    elsa.UseAgentPersistence(ea =>
    {
        ea.UseEntityFrameworkCore(eaf =>
        {
            eaf.UseSqlServer(configuration.GetConnectionString("Default")!,new Elsa.EntityFrameworkCore.ElsaDbContextOptions()
            {
                SchemaName="ElsaAGNT",

            });
        });
    });
    elsa.AddSwagger();
    elsa.UseAgentsApi();
    elsa.AddActivitiesFrom<Program>();
    elsa.AddWorkflowsFrom<Program>();
    
});

services.AddCors(cors =>
{
    cors.AddDefaultPolicy(policy =>
    {
        policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().WithExposedHeaders("*");
    });
});

services.AddRazorPages(options =>
{
    options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
});

var app = builder.Build();

app.UseHttpsRedirection();
// app.UseBlazorFrameworkFiles();
app.MapStaticAssets();
app.UseRouting();
app.UseCors();
app.UseStaticFiles();
app.UseSwaggerGen();
app.UseAuthentication();
app.UseAuthorization();
app.UseWorkflowsApi();
app.UseWorkflows();
app.MapFallbackToPage("/_Host");

app.Run();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions