.NET Framework Developer Center > .NET Development Forums > Building Development and Diagnostic Tools for .Net > How does .NET find dlls corresponding to namespaces it imports?
Ask a questionAsk a question
 

AnswerHow does .NET find dlls corresponding to namespaces it imports?

  • Sunday, October 25, 2009 8:18 AMlpszDan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I type in code
    Imports this.and.this
    but how does it know what dll to load? Is it registered somewhere?
    How could I know if that namespace is available on my machine?
    Thanks
    Dan

Answers

  • Monday, October 26, 2009 3:36 PMKarel ZikmundMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This is actually language compiler feature. You give references (/r switch in C# and VB compilers) to the compiler and it will scan all available classes with their namespaces in these references. That's how compilers can find out where particular class is defined.
    Visual Studio has its own built-in way how to find which assemblies to give to the compilers as reference assemblies. You can check it out in the build logs.

    Note that the same namespace can be implemented in multiple assemblies (e.g. System namespace in mscorlib.dll and System.dll).

    -Karel

All Replies

  • Monday, October 26, 2009 3:36 PMKarel ZikmundMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    This is actually language compiler feature. You give references (/r switch in C# and VB compilers) to the compiler and it will scan all available classes with their namespaces in these references. That's how compilers can find out where particular class is defined.
    Visual Studio has its own built-in way how to find which assemblies to give to the compilers as reference assemblies. You can check it out in the build logs.

    Note that the same namespace can be implemented in multiple assemblies (e.g. System namespace in mscorlib.dll and System.dll).

    -Karel