473,788 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reflection in ASP.NET - Strange behavior?

I have the following code encapsulated in an ascx page (user control):

namespace MyCompany.Web.U serControls
{
[most of my code]
string webform_namespa ce = this.GetType(). Namespace.ToStr ing();
}

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
Nov 17 '05 #1
1 1281
Justice,

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

string webform_namespa ce = this.GetType(). BaseType.Namesp ace.ToString();
Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online .microsoft.com

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

--------------------
From: ju**********@ho tmail.com (Justice Gray)
Newsgroups: microsoft.publi c.dotnet.framew ork.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: <56************ *************@p osting.google.c om>
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: gr**********@go ogle.com
NNTP-Posting-Date: Wed, 15 Oct 2003 16:08:55 +0000 (UTC)
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.s yr.edu!news.max well.syr.edu!po stnews1.google. com!no
t-for-mailXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1843 51
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet

I have the following code encapsulated in an ascx page (user control):

namespace MyCompany.Web.U serControls
{
[most of my code]
string webform_namespa ce = this.GetType(). Namespace.ToStr ing();
}

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


Nov 17 '05 #2

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

Similar topics

1
2660
by: Steve | last post by:
Hello, I'm encountering an unexpected behavior when using the "new" modifier in a derived class to hide an inherited base class property. I use "new" intentionally so I can change the Type of the property in the derived class, and I can use the derived class as expected through standard instantiation. The unexpected behavior occurs when I try to set gather the PropertyInfo for the derived class property via Reflection. I get an...
0
1180
by: CLEAR-RCIC | last post by:
Hi All: I have a .dll that deserializes a class. When I call this .dll from an .exe it works fine. When I call the .dll using reflection (calling the .dll on the fly) I get an error on the line that deserializes. I found a few other people on google who had observed the same behavior and said it was due isolation that happens when System.Reflection.Assembly.LoadFile (during reflection) is called. Has anyone had any experience with...
0
1108
by: MWells | last post by:
I have a simple VS.NET solution with Project "A" as a web app and Project "B" as a class library. "B" does some HTML rendering, and uses reflection to locate and load the necessary rendering classes. The behavior I'm trying to create is that; A gives a rendering instruction to B B uses reflection to locate the specified Renderer
1
1507
by: Alexander Inochkin | last post by:
Hi! I found same strange behavior of ASP.NET. It is possible this is the bug. Follow the steps:
1
17829
by: Patrick | last post by:
Has been trying to get an ASP.NET DLL's modification date/time for the "release date/time" to be displayed on the page's footer Using: System.Reflection.Assembly asm=System.Reflection.Assembly.GetExecutingAssembly(); appVer = asm.GetName().Version.ToString(); // get the location of our executing assembly System.IO.FileInfo inf = new System.IO.FileInfo(asm.Location);
0
3574
by: ivb | last post by:
Hi all, I am using DB2 8.1.11.1 on NT with ASP.NET 1.1 When application make connection to database (via ADO.NET), it set "Connection timeout" parameter to 30 seconds. After, when my webpage requests database, and query execution time exceeds 30 seconds, the following error reported: ===
6
2275
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to the same method (aka delegate?). I use the Tag property within this method to determine what user action is taking place. Very simple: When adding toolbar button: tbButton.Click += new...
1
2978
by: Nicholas Palmer | last post by:
Hi all, Got a question about the AspCompat=true page property. First a little background. We have an ASP.NET app that uses two COM components. The first is the Microsoft OWC 11 components and the second is a custom VB6 COM component. So I was reading about AspCompat=true and it seemed like it would be a good fit for our app. From what I can tell both of the COM components that we are using are STA and we are creating the components in...
2
2981
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have an asp.net web page (say page.aspx) which derives from a custom base page object (CustomPage : BasePage : System.Web.UI.Page) Which has a method called DoSomething(params). My web page contains a UserControl (say Control.ascx). In the control class, i want to call the DoSomething method. I cannot use type cast since in fact the base class Page structure is a little more complex (see bottom of post). Hence i cannot do:
0
10366
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9967
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.