473,722 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(objec t sender, System.EventArg s 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 InvalidCastExce ption.


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 3431
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.suchmetho d" 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.suchmetho d" 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.publi c.dotnet.framew ork.aspnet
Subject: Invalid Cast Exception Calling Bsse Class Method
Date: Thu, 05 Feb 2004 17:17:55 -0800
Reply-To: ma**@arcabama.c om
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/cOseAWQeTU9VbpB hPoz5/j6hAV/j8li6xTgHzmXDcm xQ/GMTklLR061Y93bv 9ce
7XJaHvw!wNc9PkA 99stfe8RVxC5nlf j4LCU4XGyTYIGY6 8FY3FF5EUOl06H+ CDehg1zYu0vINsA t
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.ph x.gbl!cpmsftngx a06.phx.gbl!TK2 MSFTNGP08.phx.g bl!newsfeed00.s u
l.t-online.de!t-online.de!news-spur1.maxwell.s yr.edu!news.max well.syr.edu!el
nk-pas-nf1!newsfeed.ea rthlink.net!pd7 cy1no!shaw.ca!b order1.nntp.ash .giganews
..com!border2.n ntp.sjc.giganew s.com!border1.n ntp.sjc.giganew s.com!nntp.giga ne
ws.com!local1.n ntp.sjc.giganew s.com!news.giga news.com.POSTED !not-for-mail
Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2079 37
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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(objec t sender, System.EventArg s 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 InvalidCastExce ption.

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.m icrosoft.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.publi c.dotnet.framew ork.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.m icrosoft.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.publi c.dotnet.framew ork.aspnet
Message-ID: <8X************ **@cpmsftngxa07 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Lines: 39
Path: cpmsftngxa07.ph x.gbl
Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2080 01
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.suchmetho d" 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.m icrosoft.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.publi c.dotnet.framew ork.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.publi c.dotnet.framew ork.aspnet
Subject: Re: Invalid Cast Exception Calling Bsse Class Method
Date: Fri, 06 Feb 2004 06:46:36 -0800
Reply-To: ma**@arcabama.c om
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-Ck9wYveoLAiVuS3 Txib3Jb83gUzDx7 ajM4XhtqRdKcW6q QBTXbHaXpXkzsfL +/gg1WM9z8QY
BjXYELi!9jhPnJu 7OrJGgKaIWYHRIu IXddHwpK4lBfdgl F/rRlFnfhOU0bL0uT poTlU45OmhHm7t
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.ph x.gbl!cpmsftngx a06.phx.gbl!TK2 MSFTNGP08.phx.g bl!newsfeed00.s u
l.t-online.de!t-online.de!newsf eed.gamma.ru!Ga mma.RU!news.max well.syr.edu!el
nk-pas-nf1!newsfeed.ea rthlink.net!new sfeed3.easynews .com!core-easynews!newsf
eed1.easynews.c om!easynews.com !easynews!borde r1.nntp.sjc.gig anews.com!nntp. g
iganews.com!loc al1.nntp.sjc.gi ganews.com!news .giganews.com.P OSTED!not-for-ma
il
Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2080 49
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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.suchmetho d" 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.m icrosoft.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.publi c.dotnet.framew ork.aspnet
Message-ID: <jT************ *@cpmsftngxa07. phx.gbl>
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Lines: 9
Path: cpmsftngxa07.ph x.gbl
Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2082 80
NNTP-Posting-Host: tomcatimport2.p hx.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.m icrosoft.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.publi c.dotnet.framew ork.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.m icrosoft.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.publi c.dotnet.framew ork.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.publi c.dotnet.framew ork.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.publi c.dotnet.framew ork.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
1817
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 changes to the code. Is there any difference in project settings or something else between v1.0 and v1.1? Thanks in advance. -- Raj
3
13883
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 values. This class called ListItem have got two private variable, one is a string containing the visual value, the other one is a UDT variable. It is a struct called
13
28260
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 command methods. This is exactly what the Microsoft Data Access Application Block assembly does but I coded my own simple, custom class. I have a method named "ExecuteAggregate" that takes in a sql string like
3
2290
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 DataSet ' Create connection Dim cn As New OleDbConnection With cn .connectionstring =
7
3622
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 get to item 250 i get a "system.invalid cast exception" and "specified cast is not valid". Once i get this error and try to go to the next record.. every record after gets the same error... It's like the com connection to outlook has been lost....
10
2777
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 like manufacturers, makes, modes, etc. of cars. I have created a generic "datacollection" class and a generic "dataobject" class to represent the table and the rows within that table as a collection of objects with generic properties for...
7
9536
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 gives no problems whatsoever. However, upon shutdown an exception pops up: "The string binding is invalid" If I call the singleton method from inside a purely unmanaged class, I
2
2175
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. -------------------------------------------------------------------------------- Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/in configuration or <%@ Page EnableEventValidation="true"...
20
2905
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 through some LINQ queries. But how to cast? ( See the below, modified from somebody else's code. The problem is the query 'stops' (throws a cast exception) at "3", and never gets to "violet".
0
8867
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9239
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9158
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5996
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3208
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2606
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2148
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.