Invalid Cast Exception Calling Bsse Class Method

N

Nick Flandry

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.

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

- Nick
 
S

Steven Cheng[MSFT]

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.)
 
N

Nick Flandry

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
 
S

Steven Cheng[MSFT]

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.)
 
M

Michael Graham

----------------------------------------------------------------------------
----------------------------------------------------------------------
NNTP-Posting-Date: Thu, 05 Feb 2004 19:17:57 -0600
From: Nick Flandry <[email protected]>
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: (e-mail address removed)
Message-ID: <[email protected]>
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!wNc9PkA99stfe8RVxC5nlfj4LCU4XGyTYIGY68FY3FF5EUOl06H+CDehg1zYu0vINsAt
Ow==
X-Complaints-To: (e-mail address removed)
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!TK2MSFTNGP08.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!border1.nntp.ash.giganews
..com!border2.nntp.sjc.giganews.com!border1.nntp.sjc.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.

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: (e-mail address removed) (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: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (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: <[email protected]>
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: (e-mail address removed) (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 <[email protected]>
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: (e-mail address removed)
Message-ID: <[email protected]>
References: <[email protected]>
<[email protected]>
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-Ck9wYveoLAiVuS3Txib3Jb83gUzDx7ajM4XhtqRdKcW6qQBTXbHaXpXkzsfL+/gg1WM9z8QY
BjXYELi!9jhPnJu7OrJGgKaIWYHRIuIXddHwpK4lBfdglF/rRlFnfhOU0bL0uTpoTlU45OmhHm7t
iQ==
X-Complaints-To: (e-mail address removed)
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!TK2MSFTNGP08.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.nntp.sjc.giganews.com!nntp.g
iganews.com!local1.nntp.sjc.giganews.com!news.giganews.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: <[email protected]>
<[email protected]>
<[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (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: <[email protected]>
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: (e-mail address removed) ("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: (e-mail address removed) ("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 Documents/quickreference.doc

Here are a couple quick notes:
Go into TomCat, File menu - Properties and change the settings to:
Account: (e-mail address removed)
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: (e-mail address removed) (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.
 
M

Michael Graham[MSFT]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top