Default Project Namespace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tank

    Default Project Namespace

    How do I get the default namespace of the project programatically ?

    For example, the following code loads the embedded resource in the assembly
    and "MyNS" is the default namespace.

    assembly.GetMan ifestResourceSt ream("MyNS.Test .Rtf");

    I do not want to hardcode it. I wish to have something like this:

    assembly.GetMan ifestResourceSt ream(GetDefault NameSpace()+".T est.Rtf");

    Thanks.


  • Marina

    #2
    Re: Default Project Namespace

    The default namespace is just a VS.NET project setting for convenience. It
    has no meaning in the .NET framework.

    You probably need to get the currently executing assembly, and use its name.

    "Tank" <anonymous@disc ussions.microso ft.com> wrote in message
    news:uj1pu5QkEH A.3648@TK2MSFTN GP09.phx.gbl...[color=blue]
    > How do I get the default namespace of the project programatically ?
    >
    > For example, the following code loads the embedded resource in the[/color]
    assembly[color=blue]
    > and "MyNS" is the default namespace.
    >
    > assembly.GetMan ifestResourceSt ream("MyNS.Test .Rtf");
    >
    > I do not want to hardcode it. I wish to have something like this:
    >
    > assembly.GetMan ifestResourceSt ream(GetDefault NameSpace()+".T est.Rtf");
    >
    > Thanks.
    >
    >[/color]


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: Default Project Namespace

      Tank <anonymous@disc ussions.microso ft.com> wrote:[color=blue]
      > How do I get the default namespace of the project programatically ?
      >
      > For example, the following code loads the embedded resource in the assembly
      > and "MyNS" is the default namespace.
      >
      > assembly.GetMan ifestResourceSt ream("MyNS.Test .Rtf");
      >
      > I do not want to hardcode it. I wish to have something like this:
      >
      > assembly.GetMan ifestResourceSt ream(GetDefault NameSpace()+".T est.Rtf");[/color]

      The default project namespace is a VS.NET concept, not a .NET framework
      concept. You could find the namespace of the current type though, if
      you wanted.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Matt

        #4
        Re: Default Project Namespace

        Tank,

        I am sure you mean you want to get the current namespace as it is defined in
        the top of your class, this is automatically set from your default namespace
        setting within the project each time you add a class. Look at the
        MethodBase object for getting current information about your class or exe.

        HTH,

        Matt

        "Tank" <anonymous@disc ussions.microso ft.com> wrote in message
        news:uj1pu5QkEH A.3648@TK2MSFTN GP09.phx.gbl...[color=blue]
        > How do I get the default namespace of the project programatically ?
        >
        > For example, the following code loads the embedded resource in the[/color]
        assembly[color=blue]
        > and "MyNS" is the default namespace.
        >
        > assembly.GetMan ifestResourceSt ream("MyNS.Test .Rtf");
        >
        > I do not want to hardcode it. I wish to have something like this:
        >
        > assembly.GetMan ifestResourceSt ream(GetDefault NameSpace()+".T est.Rtf");
        >
        > Thanks.
        >
        >[/color]


        Comment

        Working...