Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingMethodException Method not found: 'Void OrchardCore.Workflows.Helpers.ServiceCollectionExtensions.AddActivity (OCC-304) #509

Closed
carlosmorenoaguilera opened this issue Nov 18, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@carlosmorenoaguilera
Copy link

carlosmorenoaguilera commented Nov 18, 2024

Describe the bug

System.MissingMethodException: Method not found: 'Void OrchardCore.Workflows.Helpers.ServiceCollectionExtensions.AddActivity(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
at OrchardCore.Commerce.WorkflowStartup.ConfigureServices(IServiceCollection services)
at OrchardCore.Environment.Shell.Builders.ShellContainerFactory.CreateContainerAsync(ShellSettings settings, ShellBlueprint blueprint)
at OrchardCore.Environment.Shell.Builders.ShellContextFactory.CreateDescribedContextAsync(ShellSettings settings, ShellDescriptor shellDescriptor)
at OrchardCore.Environment.Shell.Builders.ShellContextFactory.OrchardCore.Environment.Shell.Builders.IShellContextFactory.CreateShellContextAsync(ShellSettings settings)
at OrchardCore.Environment.Shell.ShellHost.GetOrCreateShellContextAsync(ShellSettings settings)
at OrchardCore.Environment.Shell.ShellHost.GetScopeAsync(ShellSettings settings)
at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

To Reproduce

  1. Create new blank site dotnet new occms
  2. Add follow packages:
  <ItemGroup>
    <PackageReference Include="OrchardCore.Commerce" Version="2.1.0" />
    <PackageReference Include="OrchardCore.Commerce.Inventory" Version="2.1.0" />
    <PackageReference Include="OrchardCore.Commerce.Payment" Version="2.1.0" />
    <PackageReference Include="OrchardCore.Commerce.Payment.Exactly" Version="2.1.0" />
    <PackageReference Include="OrchardCore.Commerce.Tax" Version="2.1.0" />
    <PackageReference Include="Lombiq.HelpfulLibraries.OrchardCore" Version="11.0.0" />
    <PackageReference Include="OrchardCore.Logging.NLog" Version="2.0.2" />
    <PackageReference Include="OrchardCore.Application.Cms.Targets" Version="2.0.2" />
  </ItemGroup>

set this on Program.cs:


using OrchardCore.Logging;
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseNLogHost();

builder.Services
    .AddOrchardCms()
// // Orchard Specific Pipeline
// .ConfigureServices( services => {
// })
// .Configure( (app, routes, services) => {
// })
;

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

//app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseOrchardCore();
app.Run();


Go to admin dashboard >> Features and Install

Screenshot 2024-11-17 184024

and immediately get an error

Screenshot 2024-11-17 184044

Expected behavior

not get an error while trying to install

Jira issue

@carlosmorenoaguilera carlosmorenoaguilera added the bug Something isn't working label Nov 18, 2024
@github-actions github-actions bot changed the title MissingMethodException Method not found: 'Void OrchardCore.Workflows.Helpers.ServiceCollectionExtensions.AddActivity MissingMethodException Method not found: 'Void OrchardCore.Workflows.Helpers.ServiceCollectionExtensions.AddActivity (OCC-304) Nov 18, 2024
@sarahelsaig
Copy link
Contributor

Sorry for the late reply, could you check if it works for you using the Cloudsmith package instead of the NuGet?
I think this has been already fixed in the main branch, and we will publish a new major release in NuGet soon. So if possible, please use the preview package from Cloudsmith in the mean time.

@carlosmorenoaguilera
Copy link
Author

thanks seems works with preview packages.

@jeff-techstension
Copy link

@sarahelsaig using the preview build fixed that problem but uncovered another one. When you turn on the commerce feature it n no longer failed with AddActivity. However, when you tried to load the content types page it throws a missing service exception.

InvalidOperationException: Unable to resolve service for type 
'OrchardCore.Commerce.Services.IFieldsOnlyDisplayManager' 
while attempting to activate 
'OrchardCore.Commerce.Drivers.OrderContentTypeDefinitionDisplayDriver'.

@Mohitkmr1322
Copy link

@sarahelsaig @wAsnk I am getting the same missing service exception while trying to load the content types.
May I know the reason and any solution how we can fix this.

Bug:
InvalidOperationException: Unable to resolve service for type
'OrchardCore.Commerce.Services.IFieldsOnlyDisplayManager'
while attempting to activate
'OrchardCore.Commerce.Drivers.OrderContentTypeDefinitionDisplayDriver'.

@sarahelsaig
Copy link
Contributor

sarahelsaig commented Jan 28, 2025

@Mohitkmr1322 which version are you using?
Can you check if you have the same problem using the latest preview package.

Also to both @Mohitkmr1322 and @jeff-techstension :
Can you go to Admin > Configuration > Features and check if you have the "Orchard Core Commerce - Content Fields" feature enabled? It may be a problem with the feature not enabling by default. If this is the problem, then this should be continued at #456.

@jeff-techstension
Copy link

@sarahelsaig think your right. I dont have content fields in the list. Will go review that issue and see if i have anything to add.

@sarahelsaig
Copy link
Contributor

Thank you for your feedback, Jeff. I will try to investigate on my end as well.
Once this issue is resolved, I will publish a new NuGet release.

@sarahelsaig
Copy link
Contributor

I've confirmed, this is the same as #456. I will attempt to fix it asap, but this issue can be closed as duplicate just to keep things ordered. Until it's resolved, please see the workaround described in the issue description:

Until this is fixed, explicitly adding each project reference to the web csproj is a viable workaround:

 <ItemGroup>
   <PackageReference Include="OrchardCore.Commerce" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.Abstractions" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.AddressDataType" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.ContentFields" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.Inventory" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.MoneyDataType" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.Payment" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.Payment.Exactly" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.Payment.Stripe" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.Promotion" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Commerce.Tax" Version="2.1.1-preview-251" />
   <PackageReference Include="OrchardCore.Logging.NLog" Version="2.1.4" />
   <PackageReference Include="OrchardCore.Application.Cms.Targets" Version="2.1.4" />
 </ItemGroup>

@sarahelsaig
Copy link
Contributor

@carlosmorenoaguilera @Mohitkmr1322 @jeff-techstension

We have released a new version on NuGet! It uses Orchard Core 2.1 and you don't have to do the above mentioned workaround any more either. So for example this is enough:

  <ItemGroup>
    <PackageReference Include="OrchardCore.Commerce" Version="3.0.0" />
    <PackageReference Include="OrchardCore.Logging.NLog" Version="2.1.4" />
    <PackageReference Include="OrchardCore.Application.Cms.Targets" Version="2.1.4" />
  </ItemGroup>

@jeff-techstension
Copy link

That's awesome @sarahelsaig. I'll give it a whirl later on today or over the weekend and let you know how it goes. Thanks a bunch.

@jeff-techstension
Copy link

Took me a moment to get around to it @sarahelsaig. Can confirm this fixes it. Thank you.

@sarahelsaig
Copy link
Contributor

Glad to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants