473,406 Members | 2,705 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,406 software developers and data experts.

ASP .Net PageBase Inherit

Hi there,

I am starting on an ASP .Net project. I have some examples of using a base
class for pages to inherit from to allow additional properties to be used by
default. This seems like a good idea to me.

I have a namespace Company.Web. I have created a PageBase.vb file with a
PageBase class containing the the properties required. This class also
inherits the System.Web.UI.Page class.

Ive compiled my project then tried to create a new aspx page. The page is
within the same namespace and i have changed the Inherits System.Web.UI.Page
to being Inherits Company.Web.PageBase

But Visual Studio will not allow me to open the page in the Designer View.

The error is

---

The file could not be loaded into the Web Forms designer. please correct the
following error and then try loading it again:

The designer could not be shown for this file because none of the classes
within it can be displayed. The designer inspected the following classes in
the file:

Index --- The base class 'Company.Web.PageBase' could not be loaded. Ensure
the assembly has been referenced or built if it is part of the project.

Make sure all of the classes used in the page are built or referenced in the
project.

---

I have looked at the help and checked the CodeBehind and Inherits setting in
the aspx page itself and it looks fine to me.

If anyone can help, that would be great.

Many Thanks.

Ben Mann.

Nov 17 '05 #1
15 5314
Hello Ben,
I have seen this happen with addins.
To determine what is causing the failure, open two instances of
VS.NET, one for the project, and one to use the debugger from to attach to
the
deven process.

Set the debugger to break on all CLR exceptions. Then try to open the
page.
Before you see the error above, you should see the exception that is
causing the error.

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

Nov 17 '05 #2
Hello Ben,
I have seen this happen with addins.
To determine what is causing the failure, open two instances of
VS.NET, one for the project, and one to use the debugger from to attach to
the
deven process.

Set the debugger to break on all CLR exceptions. Then try to open the
page.
Before you see the error above, you should see the exception that is
causing the error.

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

Nov 17 '05 #3
Thanks very much for your reply to my post. I'm still getting my feet wet as
far as ASP .Net is concerned and small problems like this seem to get me
stumped for ages!

I hope you don't mind me sending you an email asking for a tiny bit more
help though, if so, just tell me to go away.
:-)
I've attached the debugger to my VS.Net and opened the offending page, It
generates, in total, 3 exceptions when it tries to open the page. The first
two are:

A first chance exception of type 'System.Security.SecurityException'
occurred in mscorlib.dll

Additional information: Request for the permission of type
System.Web.AspNetHostingPermission, System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

and the third is the cruncher....
A first chance exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
microsoft.visualstudio.dll

Additional information: The designer could not be shown for this file
because none of the classes within it can be designed. The designer
inspected the following classes in the file:

Index --- The base class 'Company.Web.pageBase' could not be loaded.
Ensure the assembly has been referenced or built if it is part of the
project.

I've read up on these exceptions, but im unsure what to do about them as
they occur in VS.Net itself.

If you've got any suggestions, that'd be really helpful.

Many Thanks.

Ben Mann.
"John Soulis [MSFT]" <js***@online.microsoft.com> wrote in message
news:wi***************@cpmsftngxa06.phx.gbl...
Hello Ben,
I have seen this happen with addins.
To determine what is causing the failure, open two instances of
VS.NET, one for the project, and one to use the debugger from to attach to
the
deven process.

Set the debugger to break on all CLR exceptions. Then try to open the
page.
Before you see the error above, you should see the exception that is
causing the error.

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

Nov 17 '05 #4
Are you making a reference to any properties in the base class
Company.Web.pageBase?
Here is what sounds like is going on. When you try to look at the form in
the designer, the base class runs so it can be loaded in the designer.
There is a reference to something in the base class that is causing an
error that is not being handled by the designer. I would start to comment
out parts of the code in the base class to find the culprit. If the code is
not something you want to keep private, I would take a look at it too.

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

Nov 17 '05 #5
Hi John,

Thanks for getting back to me again,
I've commented out almost the entire pageBase file, but still non luck.

Most of it is lifted from the Duwamish 7 example web app. I just want to
have a parent class with an UrlBase property, (not much to ask!).

But my VS .Net has the same trouble if i try to load up any of the Duwamish
example pages that extend the PageBase class.
I've put my code for the pageBase and example aspx page below. If you could
take a look that'd be great.

pageBase.vb:
Option Explicit On
Option Strict On

Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Data

Namespace Company.Web

'----------------------------------------------------------------
' Namespace: Company.Web
' Class: pageBase
'
' Description:
' The code-behind base class for all pages.
'----------------------------------------------------------------

Public Class pageBase

Inherits System.Web.UI.Page

' Private Shared ReadOnly Property UrlSuffix() As String
' Get
' UrlSuffix = HttpContext.Current.Request.Url.Host +
HttpContext.Current.Request.ApplicationPath
' End Get
' End Property
' Public Shared ReadOnly Property UrlBase() As String
' Get
' UrlBase = "http://" & UrlSuffix
' End Get
' End Property

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

End Class

End Namespace

and the webform1.aspx:
Option Explicit On
Option Strict On

Imports Company.Common

Namespace Company.Web

Public Class WebForm1

Inherits pageBase
'Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class

End Namespace

Many thanks,

Ben Mann
"John Soulis [MSFT]" <js***@online.microsoft.com> wrote in message
news:S$*************@cpmsftngxa06.phx.gbl...
Are you making a reference to any properties in the base class
Company.Web.pageBase?
Here is what sounds like is going on. When you try to look at the form in
the designer, the base class runs so it can be loaded in the designer.
There is a reference to something in the base class that is causing an
error that is not being handled by the designer. I would start to comment
out parts of the code in the base class to find the culprit. If the code is not something you want to keep private, I would take a look at it too.

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

Nov 17 '05 #6
Looks like we are narrowing this down.
Please try this, so I can determine if it is project specific or an issue
with VS.NET.
1 Start a new project.
2 Add a class file and name it cpagebase.vb
3 Add this code to the file.
Public Class cpagebase : Inherits System.Web.UI.Page
End Class

4 inherit the page in webform1.aspx
Public Class WebForm1
Inherits cpagebase
5 Add this code to the page load
Response.Write("test")

6 Build and browse.

What results do you get from this?

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

Nov 17 '05 #7
Hi John,

Thanks for that.
I tried the example below and it worked fine.

Im not sure what is wrong now.
If you've got any more suggestions, tha'd great.

Thanks yet again.

Ben Mann.
"John Soulis [MSFT]" <js***@online.microsoft.com> wrote in message
news:0t*************@cpmsftngxa06.phx.gbl...
Looks like we are narrowing this down.
Please try this, so I can determine if it is project specific or an issue
with VS.NET.
1 Start a new project.
2 Add a class file and name it cpagebase.vb
3 Add this code to the file.
Public Class cpagebase : Inherits System.Web.UI.Page
End Class

4 inherit the page in webform1.aspx
Public Class WebForm1
Inherits cpagebase
5 Add this code to the page load
Response.Write("test")

6 Build and browse.

What results do you get from this?

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

Nov 17 '05 #8
When you try to build the original project, does it build without errors?

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #9
Hi John,

Yes the project builds fine, and i can use the page that inherits the
pageBase fine as well.

Ben Mann.
"John Soulis [MSFT]" <js***@online.microsoft.com> wrote in message
news:gE**************@cpmsftngxa06.phx.gbl...
When you try to build the original project, does it build without errors?

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #10
Hi john,

I've also just uncommented the properties that i wanted to be inherited and
they work fine as well when the project is built and the page is view in IE.

It seems to just be a VS Designer View problem....
"John Soulis [MSFT]" <js***@online.microsoft.com> wrote in message
news:gE**************@cpmsftngxa06.phx.gbl...
When you try to build the original project, does it build without errors?

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #11
What is the imports Company.Common?
Also, remove the namespace in the webform1.aspx and make the inherits read
Company.Web.pageBase

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #12
Hi John,

Thanks again for your help.

The Company.Common is a separate project/dll where i have put some common
database access code thats to be shared between the web app and a windows
app that access the same database.

To count this out, i've created another test page consisting of only:
Public Class test
Inherits Company.Web.pageBase

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class

I think this code is including the bit thats usually folded away, generated
by default.

Thanks

Ben Mann
"John Soulis [MSFT]" <js***@online.microsoft.com> wrote in message
news:$n**************@cpmsftngxa06.phx.gbl...
What is the imports Company.Common?
Also, remove the namespace in the webform1.aspx and make the inherits read
Company.Web.pageBase

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #13
Hi Ben,
It is a VS Designer issue, but only with that page or possibly the project.
We can get a new project and page to work ok. Have you been able to run my
test? Try running it without the Company.Common or any other objects. Check
in the html to make sure there are no other objects(controls ect) on the
page. Also, try adding the test page you created from my notes to this
project and see if it will work. If it does, try adding the Company.Common
to it.

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #14
Hi John,

I've just tried opening up the test project that i put together yesterday
using the test code you sent.
Though it builds and displays in IE fine, but the VS designer won't open it.

The pages still only consist of:

cpagebase.cv:

Public Class cpagebase : Inherits System.Web.UI.Page

End Class
and WebForm1.aspx:

Public Class WebForm1

Inherits cpagebase

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Response.Write("test")

End Sub

End Class

There's not much there for it to get wrong really.
If there's anything else that you can suggest, that'd be great.

Thanks again.

Ben Mann.


"John Soulis [MSFT]" <js***@online.microsoft.com> wrote in message
news:Uh**************@cpmsftngxa06.phx.gbl...
Hi Ben,
It is a VS Designer issue, but only with that page or possibly the project. We can get a new project and page to work ok. Have you been able to run my
test? Try running it without the Company.Common or any other objects. Check in the html to make sure there are no other objects(controls ect) on the
page. Also, try adding the test page you created from my notes to this
project and see if it will work. If it does, try adding the Company.Common
to it.

Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #15
At this point, it definitly looks like a problem with the designer now that
we are seeing it in two different projects. I will see what else I can
find. Are you getting the same error message?
Thank you, John Soulis
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 17 '05 #16

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

Similar topics

7
by: Fabian Neumann | last post by:
Hi! I got a problem with font-family inheritance. Let's say I have CSS definitions like: p { font:normal 10pt Verdana; } strong { font:normal 14pt inherit;
1
by: Jeff Schmidt | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, ~ Ok, I've got some tables, and a style sheet that contains stuff to format the table. The problem I'm having is, it appears that using...
7
by: bobsled | last post by:
For class A to reuse functionality of a class B, A could either contains B or inherits from B. When should pick which? In a book the author says that "Don't inherit from a concrete class." Does...
4
by: Slavyan | last post by:
(I just started to learn C#.NET) What's the syntax in c# for a class to inherit more than one class. I know following syntax: public class MyClass : MyOtherClass { } but I need to inherit...
6
by: Mohammad-Reza | last post by:
I wrote a component using class library wizard. In my component i want to in order to RightToLeft property do some works. I can find out if user set this property to Yes or No, But if He/She set it...
0
by: Ben Mann | last post by:
Hi there, I am starting on an ASP .Net project. I have some examples of using a base class for pages to inherit from to allow additional properties to be used by default. This seems like a good...
4
by: z f | last post by:
Hi, if i use a base class for my pages PageBase inherits system.web.page can i control the title of my inheriting pages without midifying the pages directly or adding a runat=server to the title...
5
by: z f | last post by:
the HTML designer for aspx pages don't work is the page inherits from a custom pageBase. any solution? TIA.
2
by: GTalbot | last post by:
Hello fellow comp.infosystems.www.authoring.stylesheets colleagues, Imagine this situation: #grand-parent-abs-pos { height: 400px; position: absolute; width: 600px; }
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
0
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...

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.