Q: Namespaces in Assemblies

G

Guest

Hi group,

I am relatively new to .NET and am trying to wrap my brain around a concept.

Say I have Assembly A1 that contains three namespaces, N1, N2, and N3.

If I add A1 as a reference to my project, am I right in thinking that I can
perform Imports N1 and that the remaining namespaces, N2 and N3, will not be
loaded into memory? Or by the very fact that I added a reference to A1, all
namespaces and classes are loaded into memory when A1 is accessed?

Perhaps I'm overthinking this, but it seems that maybe I am on the cusp of
actually grasping the whole concept of assemblies and namespaces, and I
wanted someone to further enlighten me.

Thanks for any input.
Richard
 
M

Mattias Sjögren

Or by the very fact that I added a reference to A1, all
namespaces and classes are loaded into memory when A1 is accessed?

Yes, all publicly accessible types in that assembly can be used,
regardless which namespace they are in.


Mattias
 
J

John Murray

Perhaps I am misunderstanding your question...but will try with what I
have..


At execution time, the IL is compiled to native code and loaded into
memory. By default, only the IL that is needed is JIT'ed and loaded
into memory. As a result (If I understand your question) just because
the assembly has some code in it doesnt mean that it will be
loaded/JIT'ed at runtime.
 
S

Scott Coonce

From a simpler point of view than the other replies:

the "Imports N1" is just a shortcut to save you from typing N1.SomeClass.
It's a compiler thing versus an execution/memory/loading thing.

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top