Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8489601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:52:22+00:00 2026-06-10T21:52:22+00:00

I am trying to resolve a concrete type using the interface with a generic

  • 0

I am trying to resolve a concrete type using the interface with a generic type that it inherits from.

It all seems to work, but when I try and call a method on the resolved concrete type it throws an exception of:

{“The best overloaded method match for
‘MvcApplication2.Utilities.Common.CQRS.GetAlbumsByIdQueryHandler.Execute(MvcApplication2.Utilities.Common.CQRS.GetAlbumsByIdQuery)’
has some invalid arguments”}

Does anyone know what could be causing this? The types that resolved are correct, I think it might have something to do with the use of the dynamic type?

Thanks.


Here is my installer for the handlers:

container.Register(AllTypes.FromAssemblyContaining<IQueryHandler>()
                                        .BasedOn(typeof (IQueryHandler<>))
                                        .WithService
                                        .AllInterfaces()
                                        .LifestyleSingleton());

And the resolution is currently:

        Type queryHandlerType = typeof (IQueryHandler<>).MakeGenericType(query.GetType());
        dynamic queryHandler = _kernal.Resolve(queryHandlerType);

        return queryHandler.Handle(query);

And the relevant classes:

public interface IQueryHandler<in TQuery> : IQueryHandler where TQuery : IQuery
{
    IQueryResult Handle(TQuery query);
}


public class GetAlbumsByIdQueryHandler : IQueryHandler<GetAlbumsByIdQuery>
{
    #region IQueryHandler<GetAlbumsByIdQuery> Members

    public IQueryResult Execute(GetAlbumsByIdQuery query)
    {
        throw new NotImplementedException();
    }

    #endregion
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:52:24+00:00Added an answer on June 10, 2026 at 9:52 pm
      return queryHandler.Handle((dynamic)query);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to resolve the AccountController in my application, but it seems that I
I'm trying to resolve a reflection warning in Clojure that seems to result from
Im trying to resolve an issue where when using NHibernate with a SqlServerCeDriver that
I have a problem with Ninject trying to resolve an interface type where the
I'm trying to resolve a hostname from an ip address. I have tried using
I'm trying to create a generic method where the type is a generic interface.
I'm trying to resolve an IEnumerable of my dependencies through Autofac, but I need
I am trying to find a solution that will resolve a recurring deadlock situation
We are trying to resolve a deadlock problem. The transaction that is getting rolled
I am trying to resolve a TimeSpan using Unity . Executing the container Resolve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.