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

Invalid Cast Exception Calling Bsse Class Method

I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS 5), but fails on IIS 6 running on a Win2003 server.

The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide
some common functionality. The Page_Load handler the failing webpage starts out like this:

public class index : SitePage {

/* snip */

protected override void Page_Load(object sender, System.EventArgs e) {
base.Page_Load(sender, e);
...

SitePage is the custom-built class that derives from the Page class.

In other words, all I'm doing is trying to call a method in the base class to the Page.
Any<< call to a base class method throws an InvalidCastException.


Does anyone have any idea what might be causing this? Am I not allowed to call base methods in an
ASP.NET application?

- Nick
Nov 18 '05 #1
5 3386
Hi Nick,
Thanks for posting in the community!
From your description, you encountered the "Invalid Cast Exception" in a
certain ASP.NET web page which derived from a custom parent page class.
Also, the exception occured when calling the parent page class's Page_Load
function, yes?
If there is anything I misunderstood, please feel free to let me know.

As for this problem, I'd like to confirm some further things on it:
1. As you mentioned the error page's Page_Load calls the base.Page_Load
then run into the error. Are you sure that it was at that point the Error
occurs or is there any thingelse suspicious in the error page's Page_Load
method? You can add a "try .... catch" block to establish this.

2. If the exception does occur when calling the "base.Page_Load" in the
derived page's Page_Load method, would you please try creating another
virutual method in the parent page and then override the method in the
derived page and also call "base.suchmethod" in it to see whether the same
problem occurs?

3. If the error doesn't occur in #2, I think the problem may due to
something with the certain "Page_Load" method. Is there any particular
operations in the parent page's Page_Load?

Please check out the above items. If you have any questions or got any new
findings, please feel free to let me know.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
>As for this problem, I'd like to confirm some further things on it:
1. As you mentioned the error page's Page_Load calls the base.Page_Load
then run into the error. Are you sure that it was at that point the Error
occurs or is there any thingelse suspicious in the error page's Page_Load
method? You can add a "try .... catch" block to establish this.
I didn't use try/catch, but I did use multiple Response.Write()/Response.End() pairs to verify that
it was, in fact, precisely the line base.Page_Load() that caused the problem. I also used the
Response.Write()/Response.End() approach to show that execution never got "into" the base class; it
was the base.Page_Load() statement itself that blew up.
2. If the exception does occur when calling the "base.Page_Load" in the
derived page's Page_Load method, would you please try creating another
virutual method in the parent page and then override the method in the
derived page and also call "base.suchmethod" in it to see whether the same
problem occurs?


Good question. I'd done that, yes, and the same problem occurred.

- Nick
Nov 18 '05 #3
Hi Nick,

Thank you for the response. Regarding on the issue, I am
finding proper resource to assist you and we will update as soon as posible.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)

Nov 18 '05 #4


----------------------------------------------------------------------------
----------------------------------------------------------------------
NNTP-Posting-Date: Thu, 05 Feb 2004 19:17:57 -0600
From: Nick Flandry <ma**@arcabama.com>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Invalid Cast Exception Calling Bsse Class Method
Date: Thu, 05 Feb 2004 17:17:55 -0800
Reply-To: ma**@arcabama.com
Message-ID: <af********************************@4ax.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 27
X-Trace:
sv3-1bd5V2us/cOseAWQeTU9VbpBhPoz5/j6hAV/j8li6xTgHzmXDcmxQ/GMTklLR061Y93bv9ce
7XJaHvw!wNc9PkA99stfe8RVxC5nlfj4LCU4XGyTYIGY68FY3F F5EUOl06H+CDehg1zYu0vINsAt
Ow==
X-Complaints-To: ab***@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
X-Postfilter: 1.1
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!newsfeed00.su
l.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!el
nk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!shaw.ca!border 1.nntp.ash.giganews
..com!border2.nntp.sjc.giganews.com!border1.nntp.s jc.giganews.com!nntp.gigane
ws.com!local1.nntp.sjc.giganews.com!news.giganews. com.POSTED!not-for-mail
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:207937
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

I'm running into an Invalid Cast Exception on an ASP.NET application that
runs fine in my
development environment (Win2K server running IIS 5) and a test environment
(also Win2K server
running IIS 5), but fails on IIS 6 running on a Win2003 server.

The web uses Pages derived from a custom class I wrote (which itself
derives from Page) to provide
some common functionality. The Page_Load handler the failing webpage starts
out like this:

public class index : SitePage {

/* snip */

protected override void Page_Load(object sender, System.EventArgs e) {
base.Page_Load(sender, e);
...

SitePage is the custom-built class that derives from the Page class.

In other words, all I'm doing is trying to call a method in the base class
to the Page.
Any<< call to a base class method throws an InvalidCastException.

Does anyone have any idea what might be causing this? Am I not allowed to
call base methods in an
ASP.NET application?

- Nick

----------------------------------------------------------------------------
----------------------------------------------------------------------
To: Internal
From: v-******@online.microsoft.com (Steven Cheng[MSFT])
Organization: Microsoft
Date: Fri, 06 Feb 2004 09:59:14 GMT
Subject: Invalid Cast Exception Calling Bsse Class Method
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Changes:
Owner from: <none> to V-SCHANG
Product from: <none> to Visual Studio .NET Ent Arc 2003
Issue Code from: <none> to ASP.NET (Web Apps)

Comments:
PROBLEM:
The customer encountered "Invalid Cast Exception" in a certain ASP.NET web
page ,which derived
from a custom parent page class. Also, in the page's Page_Load event, it
calls its parent page's Page_Load function.
And the problem occurs on a WinServer 2003 machine rather than win2k

----------------------------------------------------------------------------
----------------------------------------------------------------------
X-Tomcat-ID: 245306397
References: <af********************************@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: v-******@online.microsoft.com (Steven Cheng[MSFT])
Organization: Microsoft
Date: Fri, 06 Feb 2004 10:28:04 GMT
Subject: RE: Invalid Cast Exception Calling Bsse Class Method
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
Message-ID: <8X**************@cpmsftngxa07.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Lines: 39
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208001
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Hi Nick,
Thanks for posting in the community!
From your description, you encountered the "Invalid Cast Exception" in a
certain ASP.NET web page which derived from a custom parent page class.
Also, the exception occured when calling the parent page class's Page_Load
function, yes?
If there is anything I misunderstood, please feel free to let me know.

As for this problem, I'd like to confirm some further things on it:
1. As you mentioned the error page's Page_Load calls the base.Page_Load
then run into the error. Are you sure that it was at that point the Error
occurs or is there any thingelse suspicious in the error page's Page_Load
method? You can add a "try .... catch" block to establish this.

2. If the exception does occur when calling the "base.Page_Load" in the
derived page's Page_Load method, would you please try creating another
virutual method in the parent page and then override the method in the
derived page and also call "base.suchmethod" in it to see whether the same
problem occurs?

3. If the error doesn't occur in #2, I think the problem may due to
something with the certain "Page_Load" method. Is there any particular
operations in the parent page's Page_Load?

Please check out the above items. If you have any questions or got any new
findings, please feel free to let me know.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


----------------------------------------------------------------------------
----------------------------------------------------------------------
To: Internal
From: v-******@online.microsoft.com (Steven Cheng[MSFT])
Organization: Microsoft
Date: Fri, 06 Feb 2004 10:29:32 GMT
Subject: Invalid Cast Exception Calling Bsse Class Method
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Changes:

Comments:
No valid email address found
----------------------------------------------------------------------------
----------------------------------------------------------------------
NNTP-Posting-Date: Fri, 06 Feb 2004 08:46:30 -0600
From: Nick Flandry <ma**@arcabama.com>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Re: Invalid Cast Exception Calling Bsse Class Method
Date: Fri, 06 Feb 2004 06:46:36 -0800
Reply-To: ma**@arcabama.com
Message-ID: <h1********************************@4ax.com>
References: <af********************************@4ax.com>
<8X**************@cpmsftngxa07.phx.gbl>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 20
X-Trace:
sv3-Ck9wYveoLAiVuS3Txib3Jb83gUzDx7ajM4XhtqRdKcW6qQBTXb HaXpXkzsfL+/gg1WM9z8QY
BjXYELi!9jhPnJu7OrJGgKaIWYHRIuIXddHwpK4lBfdglF/rRlFnfhOU0bL0uTpoTlU45OmhHm7t
iQ==
X-Complaints-To: ab***@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
X-Postfilter: 1.1
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!newsfeed00.su
l.t-online.de!t-online.de!newsfeed.gamma.ru!Gamma.RU!news.maxwell. syr.edu!el
nk-pas-nf1!newsfeed.earthlink.net!newsfeed3.easynews.com! core-easynews!newsf
eed1.easynews.com!easynews.com!easynews!border1.nn tp.sjc.giganews.com!nntp.g
iganews.com!local1.nntp.sjc.giganews.com!news.giga news.com.POSTED!not-for-ma
il
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208049
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
As for this problem, I'd like to confirm some further things on it:
1. As you mentioned the error page's Page_Load calls the base.Page_Load
then run into the error. Are you sure that it was at that point the Error
occurs or is there any thingelse suspicious in the error page's Page_Load
method? You can add a "try .... catch" block to establish this.
I didn't use try/catch, but I did use multiple
Response.Write()/Response.End() pairs to verify that
it was, in fact, precisely the line base.Page_Load() that caused the
problem. I also used the
Response.Write()/Response.End() approach to show that execution never got
"into" the base class; it
was the base.Page_Load() statement itself that blew up.
2. If the exception does occur when calling the "base.Page_Load" in the
derived page's Page_Load method, would you please try creating another
virutual method in the parent page and then override the method in the
derived page and also call "base.suchmethod" in it to see whether the same
problem occurs?


Good question. I'd done that, yes, and the same problem occurred.

- Nick

----------------------------------------------------------------------------
----------------------------------------------------------------------
X-Tomcat-ID: 243831838
References: <af********************************@4ax.com>
<8X**************@cpmsftngxa07.phx.gbl>
<h1********************************@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: v-******@online.microsoft.com (Steven Cheng[MSFT])
Organization: Microsoft
Date: Sat, 07 Feb 2004 13:08:09 GMT
Subject: Re: Invalid Cast Exception Calling Bsse Class Method
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
Message-ID: <jT*************@cpmsftngxa07.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Lines: 9
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:208280
NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182

Hi Nick,

Thank you for the response. Regarding on the issue, I am
finding proper resource to assist you and we will update as soon as posible.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security(This posting is provided "AS IS",
with no warranties, and confers no rights.)


----------------------------------------------------------------------------
----------------------------------------------------------------------
To: Internal
From: mi****@online.microsoft.com ("Mike Moore [MSFT]")
Organization: Microsoft
Date: Mon, 09 Feb 2004 18:51:26 GMT
Subject: Invalid Cast Exception Calling Bsse Class Method
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Changes:
Status from: Open: Pending research to Escalated
Owner from: V-SCHANG to michmo

Comments:
I created SRX040209603257
mgraham agreed to take the case.
----------------------------------------------------------------------------
----------------------------------------------------------------------
To: Internal
From: mi****@online.microsoft.com ("Mike Moore [MSFT]")
Organization: Microsoft
Date: Tue, 10 Feb 2004 19:25:27 GMT
Subject: Invalid Cast Exception Calling Bsse Class Method
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Changes:

Comments:
From: Michael W. Moore (DEVELOPER SUPPORT)
Sent: Tuesday, February 10, 2004 11:25 AM
To: Michael Graham
Subject: SRX040209603257 [newsgroup] 21159328 Invalid Cast Exception
Calling Bsse Class Method
Importance: High

Hi Mike,

I noticed that you posted a log into the Clarify case yesterday indicating
that you sent e-mail to the customer. With newsgroup support, we want to go
through the newsgroups rather than contacting the customer directly. Please
post your message from yesterday into the newsgroup thread.

A newsgroup quick reference guide can be found at:
http://dev-community/Shared%20Docume...kreference.doc

Here are a couple quick notes:
Go into TomCat, File menu - Properties and change the settings to:
Account: mg*****@online.microsoft.com
Full name: Michael Graham [MSFT]
Org: Microsoft

Always add this at the bottom of every post:
This posting is provided "AS IS", with no warranties, and confers no rights.

Thank you, Mike
----------------------------------------------------------------------------
----------------------------------------------------------------------
Newsgroups: microsoft.public.dotnet.framework.aspnet
From: mg*****@online.microsoft.com (Michael Graham (MS))
Organization: Microsoft
Date: Tue, 10 Feb 2004 19:27:39 GMT
Subject: RE: Invalid Cast Exception Calling Bsse Class Method
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hey Mark,

My name is Michael and I'm with the ASP .NET team. I have been asked to
look at this newsgroup issue that you have posted, since we couldn't come
to an immediate solution. If possible, would you be able to create a
simple sample that shows the issue that you are having? I have tested
this here, and I cannot reproduce your issue. It works on Windows 2000 and
Windows 2003. I'd like to try the way that you are doing this. I have
sent you an email from my main Microsoft accout. Please send me the repro
that you are using. I can send you mine, also, if you would like. Please
drop me a quick note and let me know if you would be able to zip up a quick
sample.

Thanks!

Michael

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


Nov 18 '05 #5
Hello all,

My name is Michael, and I will be working with the customer offline. I
will post the resolution to this site when we find out the problem and
resolution. Mark is currently working on something else so we will get to
this sometime next week.

Michael

Nov 18 '05 #6

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

Similar topics

6
by: Raj | last post by:
I have a c# program in which I used cast. That worked perfectly on .Net platform 1.0. When I moved to .Net 2003, I am getting the execption "Specified cast is not valid". I have not made any...
3
by: Giulio Santorini | last post by:
Hi, I've got a little problem with my C# WinForms test application. I would like to have a ComboBox showing a a visual value and some hidden values. So I build a class able to store thoose...
13
by: Jack MacRank | last post by:
Hello, I'm coding a webform application in C# (ASP.NET 1.1 SP1 with VS.NET 2003 Pro on WinXP SP2 using IIS 5.1). I created a seperate "data" class to house all the MySQL connection and sql...
3
by: John Howard | last post by:
Making the following call to a local MSAccess database works fine: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows As Integer Dim strSQL As String Dim ds As New...
7
by: Chris Thunell | last post by:
I'm trying to loop through an exchange public folder contact list, get some information out of each item, and then put it into a vb.net datatable. I run though the code and all works fine until i...
10
by: Chet Cromer | last post by:
I am creating a set of base classes and sub classes to use throughout a program I'm developing. The base class represents a generic "lookup table" from my database that contains lists of things...
7
by: Søren Dreijer | last post by:
Hi, I have a mixed C#, managed C++ and unmanaged C++ project. The managed class calls a method which exists in an unmanaged singleton class. During the entire lifetime of the application, this...
2
by: Nathan Sokalski | last post by:
I have a DataList in which the ItemTemplate contains two Button controls that use EventBubbling. When I click either of them I receive the following error: Server Error in '/' Application....
20
by: raylopez99 | last post by:
Inspired by Chapter 8 of Albahari's excellent C#3.0 in a Nutshell (this book is amazing, you must get it if you have to buy but one C# book) as well as Appendix A of Jon Skeet's book, I am going...
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?
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
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
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
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...
0
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...
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,...

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.