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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:20:46+00:00 2026-06-05T07:20:46+00:00

I want to loop over all classes which I have added in my project

  • 0

I want to loop over all classes which I have added in my project

Assembly[] foo = AppDomain.CurrentDomain.GetAssemblies();

foreach(Assembly a in foo)
{                
    foreach(Type t in a.GetTypes())
    {

    }
}

this is what I tried but I want to exclude the assemblies which are provided by .net, for example “mscorlib”

  • 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-05T07:20:47+00:00Added an answer on June 5, 2026 at 7:20 am

    One common solution would be to filter the assemblies by name, if all of your assemblies have a common prefix (if you have a more or less unique prefix).

    var foo = AppDomain.CurrentDomain.GetAssemblies()
                                     .Where(a=>a.FullName.StartsWith("MyProject."));
    

    If you are only interested in some specific types, consider using attributes for your classes, or even add one at assembly level.

    Example:

    Create an attribute:

    [AttributeUsage(AttributeTargets.Assembly)]
    public class MyAssemblyAttribute : Attribute { }
    

    add the following to your AssemblyInfo.cs:

    [assembly: MyAssemblyAttribute()]
    

    and filter the assemblies you are looking at:

    var foo = AppDomain.CurrentDomain
                       .GetAssemblies()
                       .Where(a => a.GetCustomAttributes(typeof(MyAssemblyAttribute), false).Any());
    

    Also you will find at this question interesting. In one answer it is suggested to check the fully qualified name of each assembly, but this is quite tedious, e.g.:

    //add more .Net BCL names as necessary
    var systemNames = new HashSet<string>
    {
        "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
        "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        ...
    };
    
    var isSystemType = systemNames.Contains(objToTest.GetType().Assembly.FullName); 
    

    It’s always easier to mark your assemblies (by name or attribute) than trying to identify which ones are part of the .Net framework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I want to make a function loop over all elements that have
I have an object of type Hash that I want to loop over via
I have a main report which loop over query's data on detail1 band. In
I have some divs with divs in them, which I want to loop through
I want to loop over a set of data in a folder and pass
I want to loop over a series of files in a directory in batches
I want to loop over the files that begin with '.' in directory x
I want to create a loop that will iterate over several strings, but unable
I have a daterange (from, to) that i want loop through an different intervals
I want to loop thru a file which is loaded with ajax, but it

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.