Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Reflection in ASP.NET - Strange behavior?

Reply
Thread Tools

Reflection in ASP.NET - Strange behavior?

 
 
Justice Gray
Guest
Posts: n/a
 
      10-15-2003
I have the following code encapsulated in an ascx page (user control):

namespace MyCompany.Web.UserControls
{
[most of my code]
string webform_namespace = this.GetType().Namespace.ToString();
}

Now, when I run this and output the string to the trace information, I
get the following value:

"ASP"

However, I want the value to be "MyCompany.Web.UserControls", which is
the namespace where I've defined it...pretty much the way I'd expect
this to show up if I was running this as a Windows form.

Is there any way to do this? Why is the namespace showing up as
"ASP"? Is this a default value? If so, is there any way to override
this?

Thanks,
-Justice
 
Reply With Quote
 
 
 
 
Jim Cheshire [MSFT]
Guest
Posts: n/a
 
      10-15-2003
Justice,

You need to check the Namespace of the base type. Change your code to this:

string webform_namespace = this.GetType().BaseType.Namespace.ToString();


Jim Cheshire [MSFT]
Developer Support
ASP.NET


This post is provided as-is with no warranties and confers no rights.

--------------------
>From: (Justice Gray)
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: Reflection in ASP.NET - Strange behavior?
>Date: 15 Oct 2003 09:08:54 -0700
>Organization: http://groups.google.com
>Lines: 23
>Message-ID: <>
>NNTP-Posting-Host: 64.42.208.35
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1066234135 16770 127.0.0.1 (15 Oct 2003

16:08:55 GMT)
>X-Complaints-To: groups-
>NNTP-Posting-Date: Wed, 15 Oct 2003 16:08:55 +0000 (UTC)
>Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnew s1.google.com!no
t-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:184351
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>I have the following code encapsulated in an ascx page (user control):
>
>namespace MyCompany.Web.UserControls
>{
> [most of my code]
> string webform_namespace = this.GetType().Namespace.ToString();
>}
>
>Now, when I run this and output the string to the trace information, I
>get the following value:
>
>"ASP"
>
>However, I want the value to be "MyCompany.Web.UserControls", which is
>the namespace where I've defined it...pretty much the way I'd expect
>this to show up if I was running this as a Windows form.
>
>Is there any way to do this? Why is the namespace showing up as
>"ASP"? Is this a default value? If so, is there any way to override
>this?
>
>Thanks,
>-Justice
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AVG Email Scanner activating at strange times with strange IP addresses dennispublic@hotmail.com Computer Support 1 08-26-2006 04:27 AM
Managed C++ Web Service - strange reflection problems Ray Deese ASP .Net Web Services 0 05-06-2004 06:16 PM
Reflection and COM Alan Seunarayan ASP .Net 3 01-14-2004 10:56 PM
[Reflection] Is it possible to Invoke a static method? [Gauthier] ASP .Net 2 12-03-2003 03:00 PM
Question About Strange 'C' Code Syntax ( Well strange to me anyway ) Harvey Twyman C Programming 8 10-25-2003 05:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57