Results 1 to 9 of 9

Thread: *RESOLVED* .NET Namespaces

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    7

    *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.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    7
    Thanks. It makes sense suddenly.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    hrmmm.... I get it now.

    So is there a way to browse the namespaces rather than the assembly itself?

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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?

  8. #8
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    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/

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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
  •  



Click Here to Expand Forum to Full Width