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

Error-- Specified cast is not valid

Greetings all,

I'm receiving this error when I attempt to pull data, in
the form of an ArrayList out of a Session.

ArrayList al = new ArrayList();
al = (ArrayList)Session["myArrayList"]; // error here

How can this cast be invalid, when the session data IS an
ArrayList??

What's going on here, but more importantly how do I fix
this?

Also note that the same code has worked in the past.

Thanks,
Justin
Nov 18 '05 #1
1 1316
Anything you grab out of the Session has to be put in there first. Check to
see whether it exists before referncing it. Example:

ArrayList al
if (Session["myArrayList"] != null)
al = (ArrayList)Session["myArrayList"];

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Justin" <an*******@discussions.microsoft.com> wrote in message
news:0a****************************@phx.gbl...
Greetings all,

I'm receiving this error when I attempt to pull data, in
the form of an ArrayList out of a Session.

ArrayList al = new ArrayList();
al = (ArrayList)Session["myArrayList"]; // error here

How can this cast be invalid, when the session data IS an
ArrayList??

What's going on here, but more importantly how do I fix
this?

Also note that the same code has worked in the past.

Thanks,
Justin

Nov 18 '05 #2

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

Similar topics

0
by: Omavlana | last post by:
Hi, I am getting the above error "specified cast is not valid" while sending the parameter to crystal report through VB.NET. Here is my code.. '*********** Dim paramFields As New...
4
by: SRLoka | last post by:
I have an application that has five threads. All five threads write to the same MSMQ. All five threads are using the same global instance to send data to the MSMQ server(on same machine)....
0
by: Andrew | last post by:
Can someone out there help. I am using Server. Transfer from a user control to a webform and tried to follow many examples exactly as specified but cannot get around the (Specified cast is not...
1
by: LIN | last post by:
Hello, We are deploying an ASP.NET web application on to a windows 2000 machine which has .NET 1.0 framework and IIS 5.0. I get an error: Specified cast is not valid. I am deploying this...
5
by: Alan Silver | last post by:
Hello, I have an ASP.NET page where I am grabbing an SqlDataReader and using it to populate some controls on the form. Amongst the fields pulled out of the table are two integer fields, which I...
4
by: Web Team | last post by:
Hi All, When I run the below code, I get error 'Specified cast is not valid' on line 163 Dim Address As OldInfra.BS7666.Address = BS7666AddressCollection.GetSingleAddress(str_UPRN) 164...
0
by: Genival P.Carvalho | last post by:
Hello folks, First sorry my bad english. I will try to implement a IExtenderProvider + Verbs (Designer). When compile tha follow code its compile fine, but whem drag resulting componet under form...
1
by: planet | last post by:
Hi, I wish I can solve this problem not having recode the sub. Here is goes: I got this error' specified cast is not valid' at the second line. from the code Sub...
0
by: Hemangi | last post by:
hi friends, I have one problem with VSTO 2005. As I try to open new project using word document in VSTO 2005, I am getting error Specified cast is not valid...and the project is not opening.Please...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
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...

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.