473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How can I retrieve the default namesace of an assembly?

jj
I have an Assembly object that I need to get a resource stream from.
The name of the resource is of course based upon the default namespace,
not the assembly name. Is there a way to use reflection to get the
default namesace?

Thank you,

jj

Dec 19 '05 #1
4 7292
jj,

There is no such thing as a default namespace for an assembly. An
assembly can contain types in any number of namespaces.

You should use attributes in your assembly (they can be applied on the
assembly level) to indicate what the resources to load are (since they seem
to be based in some part on the assembly).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"jj" <jo**************@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I have an Assembly object that I need to get a resource stream from.
The name of the resource is of course based upon the default namespace,
not the assembly name. Is there a way to use reflection to get the
default namesace?

Thank you,

jj

Dec 19 '05 #2
"jj" <jo**************@gmail.com> wrote in news:1135018800.397615.108390
@g43g2000cwa.googlegroups.com:
I have an Assembly object that I need to get a resource stream from.
The name of the resource is of course based upon the default namespace,
not the assembly name. Is there a way to use reflection to get the
default namesace?


Not sure, but what I've done in the past is use 'GetManifestResourceNames'
to list all of the resources. Then I pick the one I'm looking for. This
can be better since different resources may be in different Namespaces.

-mdb
Dec 19 '05 #3
jj
Thank you for the quick response,

What I have is an xslt file in the source directory of my project with
a build action of "Embedded Resource". When I make a call to
Assembly.GetManifestResourceStream() I need the assembly and the full
name. This full name is prefixed by the default namespace that is
defined in the properties. I would like to avoid having to use the
assembly path, the default namespace, and the class name to get to the
resource and instead get the default namespace from the Assembly
object. I can do this if I make sure that the default namespace is the
same as the assembly name, as it is by default, but since this is for a
framework for other developers to use, I would like to avoid this
requirement.

Dec 19 '05 #4
jj <jo**************@gmail.com> wrote:
Thank you for the quick response,

What I have is an xslt file in the source directory of my project with
a build action of "Embedded Resource". When I make a call to
Assembly.GetManifestResourceStream() I need the assembly and the full
name. This full name is prefixed by the default namespace that is
defined in the properties. I would like to avoid having to use the
assembly path, the default namespace, and the class name to get to the
resource and instead get the default namespace from the Assembly
object. I can do this if I make sure that the default namespace is the
same as the assembly name, as it is by default, but since this is for a
framework for other developers to use, I would like to avoid this
requirement.


The "default namespace" is purely a Visual Studio construct. As Michael
suggests, you could find all the names of resources and pick the one
you're after. If you only include one XSLT file per assembly, that
should be really easy. To be honest, it would be best if other
developers specified which resource name to use explicitly, IMO.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Edward Diener | last post by:
Is the default 'false' for the CLSCompliant attribute at the assembly level ? Are there any tools to check for CLS compliance for the various NET languages ?
3
by: Marty | last post by:
Hi, How can I retrieve the file version of another file outside my current assembly? Thank you! Marty
4
by: Friso Wiskerke | last post by:
Hi all, Is it possible in VB.NET to retrieve a list of available classes in the current assembly? I know that there are many things you can do with the System.Reflection namespace, like...
2
by: Jeff Beem | last post by:
Hi all, I know that I can place an access database into an assembly as a resource by dropping it into the Project Explorer and setting it's "Build Action" property to Embedded Resource. How do...
2
by: Steve Barnett | last post by:
I'm trying to put together a class that retrieves version information from my assembly and am having a problem. The code below happily retrieves the AssemblyTitle and AssemblyDescription but fails...
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
5
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, I've created a class library assembly containing several string resource files, like: - TableColumns.resx - TableColumns.de.resx - General.resx - General.de.resx
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
10
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Hi everybody, I'm trying to use the new VB 2008 right now and I want to know how to preset the company name and copyright informtion in Assembly Information. In my current VB 2005, company name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.