Default Project Namespace

  • Thread starter Thread starter Tank
  • Start date Start date
T

Tank

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.GetManifestResourceStream("MyNS.Test.Rtf");

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

assembly.GetManifestResourceStream(GetDefaultNameSpace()+".Test.Rtf");

Thanks.
 
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 said:
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.GetManifestResourceStream("MyNS.Test.Rtf");

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

assembly.GetManifestResourceStream(GetDefaultNameSpace()+".Test.Rtf");

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.
 
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
 
Back
Top