Default Project Namespace

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

Marina

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

Jon Skeet [C# MVP]

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

Matt

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Default Project Namespace 2
Namespace confusion 1
Resources 6
Namespace question 2
Loading Embedded Resources/Files 2
Play Embedded Sound Resource? 6
Loading Embedded Resources 5
this embedded 1

Top