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

  • Home
  • SEARCH
  • 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 8388389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:27:48+00:00 2026-06-09T18:27:48+00:00

Possible Duplicate: Finding all Namespaces in an assembly using Reflection (DotNET) let us consider

  • 0

Possible Duplicate:
Finding all Namespaces in an assembly using Reflection (DotNET)

let us consider that i am having list of 10 to 30 dll with me i need to list out all the namespaces imported by those dll.

I have tried with following code using reflection as

string[] fileEntries = Directory.GetFiles(sDir, "*.dll");
                foreach (string fileName in fileEntries)
                {
                    Assembly assembly = Assembly.LoadFrom(fileName);
                    List<string> namespaces = new List<string>();
                    foreach (var type in assembly.GetTypes())
                    {
                        string ns = type.Namespace;
                        if (!namespaces.Contains(ns))
                        {
                            namespaces.Add(ns);
                            Console.WriteLine(ns);
                        }
                    }

                }

but it only retrives the only the namespace of those dll.

for example let us consider a program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace sample
{
    public partial class sample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string pth = filepth("D:/sample1/s.txt");
            createfile(pth);
            Response.Write("File created on path :" + pth);
        }
     }      
}

based on the above code it retrives only sample but i need to retrive all namespaces used as

**

using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;

**

can you guide me regarding it..

waiting for your valuable comments

  • 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-09T18:27:49+00:00Added an answer on June 9, 2026 at 6:27 pm

    There’s no any namespaces at run-time.
    Moreover, in the sample you provided, not every namespace from source code used (execute “Organize usings -> Remove unused usings” from the context menu).

    You can look up referenced assemblies for particular assembly, not a namespaces.
    To do what you want, you need to know every type, used (not declared, which is easy to get!) in particular assembly’s code.

    I don’t know, how it can be done without analyzing IL code.
    Hope, Cecil can help you… but it’s not easy and not reflection-only task.

    Citation from the remarks for MethodBody class in MSDN:

    You can use the token-resolution methods of the module class, such as
    ResolveType, ResolveMethod, and ResolveType, to resolve the tokens in
    the method body to Type objects, MethodInfo objects, and FieldInfo
    objects that provide detailed information about the types, methods,
    and fields accessed by the MSIL in the method body. Parsing method
    bodies requires a thorough understanding of metadata and MSIL
    instruction formats. Information can be found in the Common Language
    Infrastructure (CLI) documentation

    Do you want to learn CLI specification yourself? 🙂

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

Sidebar

Related Questions

Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm finding that dictionary
Possible Duplicate: finding all numbers less than x in a BST How would I
Possible Duplicate: Finding all cycles in graph I have a task I've been wrapping
Possible Duplicate: Finding a single number in a list Given an array of numbers,
Possible Duplicate: R: Finding patterns across multiple columns- possibly duplicated()? Dear all, Here is
Possible Duplicate: Finding local IP addresses using Python's stdlib To get my localhost IP
Possible Duplicate: finding index of an item closest to the value in a list
Possible Duplicate: Finding the Variable Name passed to a Function in C# In C#,
Possible Duplicates: Finding duplicate files and removing them. In Python, is there a concise
Possible Duplicate: optimal algorithm for finding unique divisors I have asked this question before,

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.