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 6012557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:25:17+00:00 2026-05-23T02:25:17+00:00

The SomeRepository type is not being return by GetPublicClassesFromApplicationAssembly . I want all types

  • 0

The SomeRepository type is not being return by GetPublicClassesFromApplicationAssembly. I want all types of classes extending IRepository to be returned. Can anyone see the problem?

  private Type[] GetPublicClassesFromApplicationAssembly()
  {
      return typeof (SomeRepository).Assembly.GetExportedTypes()
            .Where(t => t.IsClass)
            .Where(t => t.IsAbstract == false)
            .Where(r => r.IsAssignableFrom(typeof(IRepository<>)))
            .OrderBy(t => t.Name)
            .ToArray();
  }

  public class SomeRepository : IRepository<SomeDomainClass> {}

  public interface IRepository<T> where T : PrimaryKeyBase {}

  public class SomeDomainClass: PrimaryKeyBase {}
  • 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-05-23T02:25:18+00:00Added an answer on May 23, 2026 at 2:25 am

    SomeRepository is not assignable from IRepository<>, which is not a “real” type; it’s assignable from IRepository<SomeDomainClass>. You need to use GetInterface instead of IsAssignableFrom:

            .Where(r => r.GetInterface("IRepository`1") != null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many, if not all, of my old VC++ 6.0 MFC apps don't work in
We're using Ninject for IOC. All of our Repository objects can (and should be)
This seems like it should be simple, but I can't figure it out. I'm
The following code block runs without error but the 'data' is returned as what
I have some repository methods which can update an whole entity or its parts
I am using mvc.net with StructureMap to scan and register all repositories and services
I have a series of NUnit tests and some are failing, yet I can't
Environment: ASP.NET MVC3 C# Say I have some repository (semi-psuedo): public interface IRepository {
Some repository clones I have allow me to do this: % git pull %
I have an ASP.NET application with three areas. In the root of the application

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.