Root Namespace

Hi,
My questions is: how do I get the root namespace of an assembly (loaded by Reflection) I hope this is a simple enough question... I do need it for accessing types within the assembly.
Thanks in advance,

Alex



Answer this question

Root Namespace

  • TKent

    Hi Sammy,

    It kind of appends the root in the class file in the namespace declaration itself. So, the developer has the option to still write the namespace as he wants it to be and override it. So whatever, is the content of the namespace declaration in the class is the final one.



    Regards,
    Vikram

  • StefanH07

    Hi,

    It is always possible to  override the namespace specified in the IDE by specifying a different one in the specific class.

    The best option is to rely on the complete Type Name which you retrieve using the GetTypes() method on an assembly.

    Regards,
    Vikram

  • Solanice

    Hi,
    Ok, thanks for your replies, all working now... What I did was use the GetTypes() function to get all the types within the assembly and when I found the type I wanted, I took the Namespace property and used that. It isn't the simplest way, but it works well for me. :)

    Alex

  • Konstantin Kamanin

    Please Isn't this a simple question, or is the language missing a necessary feature
  • Andrew English

    If you specify a namespace in the file, will it override the root or append it to the root I think it's the latter.

  • Onomatopoetikon

    There is no root namespace for an assembly. The root namespace is a Visual Basic compiler feature that allows you to specify a common namespace that all your classes/modules will be put in, but it has no special meaning for the generated assembly - if you have an empty root namespace in your project and explicitly put everything in namespace Foo, the generated assembly is identical to what you'd get if you removed all the namespace Foo specifications from your code and specified it as the root namespace instead...

    What did you plan on using the assembly's root namespace for

    Best regards,
    Johan Stenberg

  • MrTufty

    Yes, it is the latter. For example, if you have specified the root namespace as 'MyCompany' in your project and had the following class and namespace declarations:



    Namespace Foo
       Public Class Bar
       
    End Class  
    End
    Namespace

    Public Class Zoo
    End Class

     


    the compiled assembly would contain the two public classes MyCompany.Foo.Bar and MyCompany.Zoo

    Best regards,
    Johan Stenberg


  • Root Namespace