|
-
Jun 30th, 2004, 07:23 AM
#1
Thread Starter
New Member
*RESOLVED* .NET Namespaces
The .NET namespace organization confuses me. I opened a new VB.NET Windows Application and headed for the object browser. It had things such as:
[list=1][*] mscorlib[*] Microsoft.VisualBasic[*] System[*] System.Data[*] System.Drawing[*] System.Windows.Forms[*] System.Xml[*] WindowsApplication1[/list=1]
While I know the entries (2) through (7) are .NET namespaces, what is the first entry mscorlib (I understand it is a deformation of Microsoft Core Library but what exactly is it - a namespace)?
Further, I opened the mscorlib node in the treeview to see other namespaces, some of which are:
[list=1][*] Microsoft[*] Microsoft.Win32[*] System[/list=1]
Opening the node System from within the mscorlib node showed me the classes within the System namespace.
However, opening the System node that is a sibling (and not the child) to the mscorlib class does not show the contained classes.
Why do they have the same namespace, System, twice - once as a child to mscorlib and once as a sibling?
And when System.Data is a reference to the Data namespace contained within the System namespace, would not setting a reference to just the System namespace take care of all contained namespaces including System.Data? Why do they have to seperately declare:
- System
- System.Data
- System.Drawing
Last edited by Techno Learner; Jun 30th, 2004 at 08:23 AM.
-
Jun 30th, 2004, 07:51 AM
#2
The answer to pretty much your whole thing is...because references are not the namespaces, they are the assemblies.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 30th, 2004, 08:13 AM
#3
Thread Starter
New Member
Thanks. It makes sense suddenly.
-
Jun 30th, 2004, 08:44 AM
#4
While crptblade is right, there's more to it than that, I think. I'm still new to this .NET thing, but I think I have an understanding of how parts of it work.
By importing the mscorlib, you have access to everything in it. But that means typing out the full namespace each time you want something out of it. Not very efficient. So you also import the System part of the assembly. This is why the object browser shows it both as a sibling and as a child.
TG
-
Jun 30th, 2004, 09:01 AM
#5
No, they are each their own assembly. Namespaces and assemblies share no direct relationship with each other. You can have two separate assemblies that both define MyNamespace as their root namespace, and all the classes defined in each assembly will show up under the same namespace when you start coding.
The object browser is based off of the assemblies, so that is why you have can System show up in every assembly node.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 30th, 2004, 09:59 AM
#6
hrmmm.... I get it now.
So is there a way to browse the namespaces rather than the assembly itself?
TG
-
Jun 30th, 2004, 11:55 PM
#7
And to add to that question, does that mean it's possible to have CHEMICAL.PLUTONIUM in C:\xang\abc.dll and CHEMICAL.URANIUM in C:\Windows\XId.dll
?
That is exactly what you've just said, right?
-
Jul 1st, 2004, 03:12 AM
#8
yay gay
hmm?
The name of the assembly has absolutly nothing to do with the name of the containing namespaces if that's your question, MS only puts them like System.Windows.Forms.Design.dll for example so you can easily see it (although it will contain other namespaces too)
\m/  \m/
-
Jul 1st, 2004, 03:18 AM
#9
OK, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|