none
Create Namespace DLL's RRS feed

  • Question

  • Hello all,

    I have a question in regards to creating DLL's and using namespaces for them....

     

    Say I create a project <NamespaceTest>. That project will have two classes (in seperapte files)

    Namespace SrcLib
    Namespace DOM 
        Public Class PersonInfoClass 
        Public Shared Function foo(ByVal PersonInfo As String) 
            Return PersonInfo.ToLower 
        End Function
    End Class
    End Namespace
    End Namespace

    Namespace SrcLib
    Namespace DAM
    Public Class PersonInfoClass
    Public Shared Function foo(ByVal PersonInfo As String)
    Return PersonInfo.ToLower
    End Function
    End Class
    End Namespace
    End Namespace 

    Now I have to refer to the namespaces as:

    Dim dam As String = NamespaceTest.SrcLib.DAM.PersonInfoClass.foo("Hello")
    Dim dom As String = NamespaceTest.SrcLib.DOM.PersonInfoClass.foo("Hello")

    Now there will be a single DLL

    NamespaceTest.dll

    I dont want that.... I really want there to be two DLL's

    SrcLib.DAM.DLL
    SrcLib.DOM.DLL

    This way if I change the shared PersonInfoClass within the DAM namespace. I will not have to recompile the entire project. Only the DAM code section.

    I do not want to make a seperate project as the result of doing so will cause me to do this:

    Dim i As String = DAM.SrcLib.DAM.PersonInfoClass.foo("Hello")  'The project name is DAM
    Dim p As String = DOM.SrcLib.DOM.PersonInfoClass.foo("Hello") 'The project Name is DOM











    printf("Love");
    Tuesday, March 10, 2009 4:40 PM

Answers

  • Set root namespace of each DLL project to empty string (or to NamespaceTest if you want to). You can do that in Project's Properties | Application | Root namespace.
    The root namespace is by default set to the DLL name, therefore you have to start with DAM/DOM when using them. If you clear the root namespace, you can use the namespaces as you define them in VB sources.

    For future VB questions i would recommend to use Visual Basic forums, for VB IDE questions there's special Visual Basic IDE forum.

    -Karel
    • Marked as answer by eBlackman Tuesday, March 10, 2009 6:41 PM
    Tuesday, March 10, 2009 6:19 PM
    Moderator