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

Finding all Web Forms in a web site using reflection

(This question has been asked previously in this group, but I don't
think it was ever really properly answered.)

I want to use reflection - preferably - to find all Web Forms in my web
site that inherit my base page class (which in turn inherits
System.Web.UI.Page). Behold the following code:

For Each asm As System.Reflection.Assembly In
System.AppDomain.CurrentDomain.GetAssemblies()
For Each mdl As System.Reflection.Module In asm.GetModules()
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassOf(GetType(MyBasePage))
..

This code only seems to list Web Forms that have actually been run. Why
is that? Even pages within the same assembly don't show up until they
have been run. Also, this behaviour is the same in the ASP.NET
Development Server and a web site published with the ASP.NET compiler
running in IIS.

Is there another, better, way to find a list of all Web Forms in a web
site?

I want to avoid having to inspect all DLL files in ~/bin/...

Dec 14 '06 #1
4 2176
Are you using the typical ASP.Net Web Site project, or are you using the
add-on Web Application project. I don't think the Web Site project forms are
truly getting pre-compiled in the same fashion that the Web Application
project or the old VS 2003 web projects did. You might experiment by
creating an app with the new web application project download over at
www.asp.net and see if there is a difference. I stopped using the web site
project for similar compilation issues.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006


"Per Bolmstedt" <to****@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
(This question has been asked previously in this group, but I don't
think it was ever really properly answered.)

I want to use reflection - preferably - to find all Web Forms in my web
site that inherit my base page class (which in turn inherits
System.Web.UI.Page). Behold the following code:

For Each asm As System.Reflection.Assembly In
System.AppDomain.CurrentDomain.GetAssemblies()
For Each mdl As System.Reflection.Module In asm.GetModules()
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassOf(GetType(MyBasePage))
..

This code only seems to list Web Forms that have actually been run. Why
is that? Even pages within the same assembly don't show up until they
have been run. Also, this behaviour is the same in the ASP.NET
Development Server and a web site published with the ASP.NET compiler
running in IIS.

Is there another, better, way to find a list of all Web Forms in a web
site?

I want to avoid having to inspect all DLL files in ~/bin/...

Dec 14 '06 #2

It's a normal "ASP.NET Web Site" created with VS2005.

I don't think precompilation is the issue since the behaviour exhibits
on a "published" web site as well.

The merge tool in the WAP template would probably let me reflect the
way I want, but I'd still be interested in explanations of the
behaviour, as well as possible solutions for an ASP.NET Web Site...

On Dec 14, 2:36 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Are you using the typical ASP.Net Web Site project, or are you using the
add-on Web Application project. I don't think the Web Site project forms are
truly getting pre-compiled in the same fashion that the Web Application
project or the old VS 2003 web projects did. You might experiment by
creating an app with the new web application project download over atwww.asp.netand see if there is a difference. I stopped using the web site
project for similar compilation issues.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Per Bolmstedt" <tom...@gmail.comwrote in messagenews:11*********************@f1g2000cwa.goo glegroups.com...
(This question has been asked previously in this group, but I don't
think it was ever really properly answered.)
I want to use reflection - preferably - to find all Web Forms in my web
site that inherit my base page class (which in turn inherits
System.Web.UI.Page). Behold the following code:
For Each asm As System.Reflection.Assembly In
System.AppDomain.CurrentDomain.GetAssemblies()
For Each mdl As System.Reflection.Module In asm.GetModules()
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassOf(GetType(MyBasePage))
..
This code only seems to list Web Forms that have actually been run. Why
is that? Even pages within the same assembly don't show up until they
have been run. Also, this behaviour is the same in the ASP.NET
Development Server and a web site published with the ASP.NET compiler
running in IIS.
Is there another, better, way to find a list of all Web Forms in a web
site?
I want to avoid having to inspect all DLL files in ~/bin/...
Dec 14 '06 #3
reflection can only see loaded assemblies. in asp.net each page is a
seperate dll (though using batching can cause some grouping). each page
dll gets loaded the first time its referenced. if the site is not
precompiled, the dll don't even exist until the page is requested
(always true in version 1).

in 1.1 the code-behinds were compiled into one dll (by vs), so
reflection could see the base classes for web pages, but the actual page
class was not available until the actual page dll was loaded.
-- bruce (sqlwork.com)
Per Bolmstedt wrote:
(This question has been asked previously in this group, but I don't
think it was ever really properly answered.)

I want to use reflection - preferably - to find all Web Forms in my web
site that inherit my base page class (which in turn inherits
System.Web.UI.Page). Behold the following code:

For Each asm As System.Reflection.Assembly In
System.AppDomain.CurrentDomain.GetAssemblies()
For Each mdl As System.Reflection.Module In asm.GetModules()
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassOf(GetType(MyBasePage))
..

This code only seems to list Web Forms that have actually been run. Why
is that? Even pages within the same assembly don't show up until they
have been run. Also, this behaviour is the same in the ASP.NET
Development Server and a web site published with the ASP.NET compiler
running in IIS.

Is there another, better, way to find a list of all Web Forms in a web
site?

I want to avoid having to inspect all DLL files in ~/bin/...
Dec 14 '06 #4

I'm using ASP.NET 2.0 and the ASP.NET Web Site template, so none of
this applies. Rather, each ASP.NET directory gets compiled into its own
App_Web_????????.dll assembly. But "pages" (classes that inherit a
class that inherits System.Web.UI.Page) in the same assembly don't show
up in the sample reflection code below unless they're explicitly
invoked, which I find odd.

But I guess the WAP template is the only real solution. Can anyone
verify that it does indeed solve my problem?

On Dec 14, 5:21 pm, bruce barker <nos...@nospam.comwrote:
reflection can only see loaded assemblies. in asp.net each page is a
seperate dll (though using batching can cause some grouping). each page
dll gets loaded the first time its referenced. if the site is not
precompiled, the dll don't even exist until the page is requested
(always true in version 1).

in 1.1 the code-behinds were compiled into one dll (by vs), so
reflection could see the base classes for web pages, but the actual page
class was not available until the actual page dll was loaded.

-- bruce (sqlwork.com)

Per Bolmstedt wrote:
(This question has been asked previously in this group, but I don't
think it was ever really properly answered.)
I want to use reflection - preferably - to find all Web Forms in my web
site that inherit my base page class (which in turn inherits
System.Web.UI.Page). Behold the following code:
For Each asm As System.Reflection.Assembly In
System.AppDomain.CurrentDomain.GetAssemblies()
For Each mdl As System.Reflection.Module In asm.GetModules()
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassOf(GetType(MyBasePage))
..
This code only seems to list Web Forms that have actually been run. Why
is that? Even pages within the same assembly don't show up until they
have been run. Also, this behaviour is the same in the ASP.NET
Development Server and a web site published with the ASP.NET compiler
running in IIS.
Is there another, better, way to find a list of all Web Forms in a web
site?
I want to avoid having to inspect all DLL files in ~/bin/...
Dec 14 '06 #5

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

Similar topics

3
by: Jaime Lucci | last post by:
Hi, how've you been? I'm trying to do a .dll that would be able to manage forms from an independient project. The dll has a method that receive a parameter which is the form I want to manage....
3
by: Bisbal | last post by:
Hi, I'd like to know if it is possible to create a form type from a string. My case: I have a DataTable with forms names (i.e frm_001_UserInfo.cs), and I'd like to create an instance of that...
6
by: JonS. | last post by:
Hi, I'm trying to create a Windows Forms portal application and need some help. What I currently have is a main application (.exe) containing an MDI form. The idea is that this main application...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
6
by: Tor Inge Rislaa | last post by:
Finding name of all forms I want to create a procedure that can loop trough all objects of type form in an application and print the name property to the debug window. TIRislaa
8
by: J.S. | last post by:
I was under the impression that frames could be used in Windows forms in earlier version of VB. However, in VB 2005 Express I don't see any such tool/control. Is SplitContainer used for this...
12
by: Peter Van Wilrijk | last post by:
Hi, In VB6 I have the following code ... Dim frmLink As Form Set frmLink = Forms.Add(stringformname) frmLink.Show 'wait until all data has been loaded Do Until frmLink.Loaded = 21 DoEvent
1
by: gnana | last post by:
Hi, I want to find controls in a ASP.NET page using System.Reflection.Assembly. I have to create an Application to set the Permission(visible/editable) for each control on the page, for this i...
7
by: joproulx | last post by:
Hi, I was wondering if there was a way with Reflection to find dynamically if an object was referencing indirectly another object. A simple example would be: Object1 | --Object2 |
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.