473,394 Members | 1,739 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.

Retrieving root namespace from within a module

I am trying to write a generic piece of code that I can copy between
projects that uses the current project's root namespace as part of its
function.

I can easily retrieve this value when I am running in a class by doing the
following:

\\\
Dim namespace As String = Me.GetType.Namespace
///

This returns the value I am looking for. However, I want to be able to place
this code into a module. Me.GetType is not valid in this circumstance as
'Me' cannot be used within a module.

I can get this working by creating an instance of an arbitrary object within
my project and calling GetType on it, but as the classes differ from one
project to another I won't be able to copy-and-paste the code without having
to make changes to it.

Is there an easy way to do what I'm trying to do?

Thanks,

--

(O)enone
Nov 21 '05 #1
3 1773
Oenone schrieb:
I am trying to write a generic piece of code that I can copy between
projects that uses the current project's root namespace as part of its
function.

I can easily retrieve this value when I am running in a class by doing the
following:

\\\
Dim namespace As String = Me.GetType.Namespace
///

This returns the value I am looking for. However, I want to be able to place
this code into a module. Me.GetType is not valid in this circumstance as
'Me' cannot be used within a module.

I can get this working by creating an instance of an arbitrary object within
my project and calling GetType on it, but as the classes differ from one
project to another I won't be able to copy-and-paste the code without having
to make changes to it.

Is there an easy way to do what I'm trying to do?


From yesterday:

http://groups.google.com/groups?thre...TNGP14.phx.gbl
In a shared method, you can use

System.Reflection.MethodBase.GetCurrentMethod.Decl aringType

to get the current type.

Armin
Nov 21 '05 #2
"Oenone" <oe****@nowhere.com> schrieb:
I am trying to write a generic piece of code that I can copy between
projects that uses the current project's root namespace as part of its
function.

I can easily retrieve this value when I am running in a class by doing the
following:

\\\
Dim namespace As String = Me.GetType.Namespace
///

This returns the value I am looking for. However, I want to be able to
place this code into a module. Me.GetType is not valid in this
circumstance as 'Me' cannot be used within a module.


\\\
Dim s As String = GetType(Module1).Namespace
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Armin Zingler wrote:
In a shared method, you can use

System.Reflection.MethodBase.GetCurrentMethod.Decl aringType

to get the current type.


That's perfect, many thanks.

--

(O)enone
Nov 21 '05 #4

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

Similar topics

2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
0
by: richwangler | last post by:
This problem should be easily reproducable if anybody has the time. I need to build the following XML programatically and decided to use the XMLSerializer. I simplified the XML (myExample.xml)...
3
by: Lee Moody | last post by:
Does anyone know where I can access programmically the value stored in the "Root Namespace" parameter of the project's common properties? To find this within the IDE, select your project name...
3
by: CCJohn | last post by:
Hi, I find that while I can use the "Namespace...End Namespace" inside my code, there is also a "Root namespace" field in the project properties dialog box under General. So where should I put...
2
by: Jeff Brown | last post by:
Hi, I suspect that this isn't possible, but I figured I'd ask. My project has a root namespace, let's say it's "Root", that applies to almost every source file (which is why I've set it as the...
32
by: toolmaster | last post by:
Since many of the modern computer languages have built-in namespace features, I can't understand why not add this feature into standard C. I've heard many people complain of the lacking of...
7
by: rfinch | last post by:
Very new to this but using the MS working with dynamics CRM 3.0 book to run web application to retrieve lead records from CRM 3.0. Have followed the book instructions on page 380-382. But am...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.