Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Invalid Cast Exception Calling Bsse Class Method

Reply
Thread Tools

Invalid Cast Exception Calling Bsse Class Method

 
 
Nick Flandry
Guest
Posts: n/a
 
      02-06-2004
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


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      02-06-2004
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.)

 
Reply With Quote
 
 
 
 
Nick Flandry
Guest
Posts: n/a
 
      02-06-2004
>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
 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      02-07-2004
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.)

 
Reply With Quote
 
Michael Graham
Guest
Posts: n/a
 
      02-11-2004


----------------------------------------------------------------------------
----------------------------------------------------------------------
NNTP-Posting-Date: Thu, 05 Feb 2004 19:17:57 -0600
From: Nick Flandry <(E-Mail Removed)>
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: http://www.velocityreviews.com/forums/(E-Mail Removed)
Message-ID: <(E-Mail Removed)>
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: (E-Mail 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!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: (E-Mail 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: <(E-Mail Removed)>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (E-Mail 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: <(E-Mail Removed)>
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 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 <(E-Mail Removed)>
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 Removed)
Message-ID: <(E-Mail Removed)>
References: <(E-Mail Removed)>
<(E-Mail Removed)>
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: (E-Mail 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!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: <(E-Mail Removed)>
<(E-Mail Removed)>
<(E-Mail Removed)>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (E-Mail 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: <(E-Mail Removed)>
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 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 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%20Docume...kreference.doc

Here are a couple quick notes:
Go into TomCat, File menu - Properties and change the settings to:
Account: (E-Mail 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 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.




 
Reply With Quote
 
Michael Graham[MSFT]
Guest
Posts: n/a
 
      02-12-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Attachment Fails with Invalid Cast Exception Reticulated Ember ASP .Net 4 01-18-2006 03:45 AM
Managing an invalid cast exception David ASP .Net 10 04-24-2005 08:11 PM
Invalid Cast Exception using Server.Transfer buzz ASP .Net 9 03-19-2005 01:29 PM
Invalid Cast Exception on Context.ApplicationInstance Mark Olbert ASP .Net 2 12-05-2003 02:43 AM
Question: Invalid Cast Exception Error VB Programmer ASP .Net 4 10-28-2003 03:13 PM



Advertisments