473,395 Members | 1,437 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,395 software developers and data experts.

Get Current NameSpace

I have a general routine in a windows app to get an embedded resource using
GetManifestResourceStream, Is it possible for when I call my routine to use
some kind of reflection to get the current namespace from where it was
called as I'm not a big fan of Hardcoding these things. ie

myBMP = MyGetResourceFunc(SomeReflectionMethod() +
".ImageFolder.Hi.bmp")

instead of...
myBMP =
MyGetResourceFunc("MyCompany.MyApp.MyComponent.Ima geFolder.Hi.bmp")

I know its not very important but thought it may be possible.
Thanks in advance.
Nov 16 '05 #1
2 39080

You can use the GetType() method inherited from object
class. This will give you the type of the current instance

You can also use Assembly.GetExecutingAssembly().FullName
namespace Garden.Flowers
{
public class Rose()
{
//will output Garden.Flower.Rose
Console.WriteLine(GetType().ToString());
}
}
-----Original Message-----
I have a general routine in a windows app to get an embedded resource usingGetManifestResourceStream, Is it possible for when I call my routine to usesome kind of reflection to get the current namespace from where it wascalled as I'm not a big fan of Hardcoding these things. ie

myBMP = MyGetResourceFunc(SomeReflectionMethod() +
".ImageFolder.Hi.bmp")

instead of...
myBMP =
MyGetResourceFunc("MyCompany.MyApp.MyComponent.Im ageFolder.Hi.bmp")

I know its not very important but thought it may be possible.
Thanks in advance.
.

Nov 16 '05 #2
many thanks tribal.

"tribal" <an*******@discussions.microsoft.com> wrote in message
news:0f****************************@phx.gbl...

You can use the GetType() method inherited from object
class. This will give you the type of the current instance

You can also use Assembly.GetExecutingAssembly().FullName
namespace Garden.Flowers
{
public class Rose()
{
//will output Garden.Flower.Rose
Console.WriteLine(GetType().ToString());
}
}
-----Original Message-----
I have a general routine in a windows app to get an

embedded resource using
GetManifestResourceStream, Is it possible for when I call

my routine to use
some kind of reflection to get the current namespace from

where it was
called as I'm not a big fan of Hardcoding these things. ie

myBMP = MyGetResourceFunc(SomeReflectionMethod() +
".ImageFolder.Hi.bmp")

instead of...
myBMP =
MyGetResourceFunc("MyCompany.MyApp.MyComponent.Im ageFolder.Hi.bmp")

I know its not very important but thought it may be possible.
Thanks in advance.
.

Nov 16 '05 #3

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

Similar topics

3
by: Tonguç Yumruk | last post by:
I'm trying to build a completely plug-in based system. One of my problems is importing a package dynamically. I'm trying to emulate the import command. The __import__() function or imp module...
3
by: Tank | last post by:
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. ...
2
by: Glen | last post by:
Hi, Is there a way to resolve the current namespace in a static method, such as Main() from within a console app? In a public method from a class instance, you can use the "this" keyword in...
3
by: vooose | last post by:
Does anyone know how to determine the current namespace in code? This appears to be necessary when you obfuscate your code and it changes the namespace, so references to 'OldNameSpace' are now...
1
by: Islam Elkhayat | last post by:
How can i get my current Namespace & current class in my webform... I tried alot but i get ASP.myformname_aspx... Is there a way to get Current Namespace, class??
1
by: Mike Walters | last post by:
Reading the current Namespace.Class, Assemble at runtime I am trying to get the Assemble, Namespace and Class name of a form at runtime. I have several assembles and namespaces in my app, I...
3
by: markroworth | last post by:
Hi everyone, I'm relatively new to vb.net and am writing my errors object to collect errors as the call stack bounces back up to the GUI. When an error occurs, I would like to grab three things:...
10
by: Francois Malgreve | last post by:
Hello everybody, I have a pretty straightforward question regarding namespace. Is there anyone who knows why the following code does not compile on the line Type t =...
1
by: puzzlecracker | last post by:
Can I find classe's namespace class Foo{ Foo (){ String namespaceName =/*Get namespace*/ } }
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.