Base solution for your next web application
Open Closed

Exceptions when using AbpDapper module #3712


User avatar
0
bilalhaidar created

Hi,

I've installed the AbpDapper nuget on both ApplicationServices and Web.Core applications.

I then added a dependency on the AbpDapperModule in the Web.Core right after the dependency for EntityFramework.

I also installed Dapper(1.50.2) and DapperExtensions. The Abp installed is 2.3.0.

I then used an IDapperRepository inside one of the ApplicationServices.

When I run the app, I get this exception:

An error occurred while starting the application.

MissingMethodException: Method not found: 'Castle.MicroKernel.Registration.ComponentRegistration`1<!0> Castle.MicroKernel.Registration.ComponentRegistration`1.UsingFactoryMethod(System.Converter`2<Castle.MicroKernel.IKernel,!!0>, Boolean)'.
Castle.Windsor.MsDependencyInjection.WindsorRegistrationHelper.RegisterServiceDescriptor(IWindsorContainer container, ServiceDescriptor serviceDescriptor)

MissingMethodException: Method not found: 'Castle.MicroKernel.Registration.ComponentRegistration`1<!0> Castle.MicroKernel.Registration.ComponentRegistration`1.UsingFactoryMethod(System.Converter`2<Castle.MicroKernel.IKernel,!!0>, Boolean)'.
Castle.Windsor.MsDependencyInjection.WindsorRegistrationHelper.RegisterServiceDescriptor(IWindsorContainer container, ServiceDescriptor serviceDescriptor)
Castle.Windsor.MsDependencyInjection.WindsorRegistrationHelper.AddServicesCollection(IWindsorContainer container, IServiceCollection services)
Castle.Windsor.MsDependencyInjection.WindsorRegistrationHelper.AddServices(IWindsorContainer container, IServiceCollection services)
Castle.Windsor.MsDependencyInjection.WindsorRegistrationHelper.CreateServiceProvider(IWindsorContainer container, IServiceCollection services)
Abp.AspNetCore.AbpServiceCollectionExtensions.AddAbp<TStartupModule>(IServiceCollection services, Action<AbpServiceOptions> optionsAction)
....Web.Startup.Startup.ConfigureServices(IServiceCollection services) in Startup.cs
+
            return services.AddAbp<DrcAppWebHostModule>(options =>
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

5 Answer(s)
  • User Avatar
    0
    bilalhaidar created

    OK, I removed all reference to the Abp.Dapper nuget and then installed the correct version that works with my project. All references are okay now.

    When I run the application, swagger takes over all is good.

    Now, when I try to access the new application services, I get this exception in the logging file:

    ERROR 2017-08-13 20:35:39,327 [35   ] Mvc.ExceptionHandling.AbpExceptionFilter - Can't create component 'Tekvention.DrcApp.Shared.CountryRegionsAppService' as it has dependencies to be satisfied.
    
    'Tekvention.DrcApp.Shared.CountryRegionsAppService' is waiting for the following dependencies:
    - Service 'Abp.Dapper.Repositories.IDapperRepository`1[[Tekvention.DrcApp.Shared.Region, Tekvention.DrcApp.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
    
    Castle.MicroKernel.Handlers.HandlerException: Can't create component 'Tekvention.DrcApp.Shared.CountryRegionsAppService' as it has dependencies to be satisfied.
    
    'Tekvention.DrcApp.Shared.CountryRegionsAppService' is waiting for the following dependencies:
    - Service 'Abp.Dapper.Repositories.IDapperRepository`1[[Tekvention.DrcApp.Shared.Region, Tekvention.DrcApp.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
    
       at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
       at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
       at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
       at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
       at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
       at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments)
       at Castle.Windsor.WindsorContainer.Resolve(Type service)
       at Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.ResolveInstanceOrNull(Type serviceType, Boolean isOptional)
       at Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetServiceInternal(Type serviceType, Boolean isOptional)
       at Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetRequiredService(Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
       at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
       at Microsoft.AspNetCore.Mvc.Controllers.DefaultControllerFactory.CreateController(ControllerContext context)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextExceptionFilterAsync>d__24.MoveNext()
    
  • User Avatar
    0
    alirizaadiyahsi created

    There is document to adding dapper. I advice you to follow this steps to add dapper. <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Dapper-Integration?searchKey=dapper">https://aspnetboilerplate.com/Pages/Doc ... Key=dapper</a>

    So it will be easy to find errors.

  • User Avatar
    0
    bilalhaidar created

    Thanks. I followed this document.

    I wasn't sure where shall I install the nuget whether on the Web.Core or the ApplicationModule?

    The app now compiles but when it is time to create that repository it fails.

    Can you look at it more please?

  • User Avatar
    0
    bilalhaidar created

    I've added an issue on github with more details: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/383">https://github.com/aspnetzero/aspnet-ze ... issues/383</a>

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    We can continue on github.