473,794 Members | 2,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

removing from collection in session variable

Hi,

On some pages, I put a collection in the session, which uses the InProc
mode. On pages where the session is extensively used (many collections are
put into it), whenever I try to remove an item from a collection using the
RemoveAt method, I get a "Index was out of range. Must be non-negative and
less than the size of the collection. Parameter name: index" error even
tough I verify in debug that the collection count is equal to 1 and I try to
RemoveAt(collec tion.count - 1) (so the index is non-negative and is less
than the size of the collection). And that error occurs if I try to remove
any index from the collection. On the other hand, on one specific page where
I put only one collection in the session (but exactly the same logic and
code apply), eveything works fine. Can someone help me out?

Thank you very much!
Nov 18 '05 #1
4 1474
"Alexandre Soares" <so*********@ho tmail.com> wrote in message
news:eM******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

On some pages, I put a collection in the session, which uses the InProc
mode. On pages where the session is extensively used (many collections are
put into it), whenever I try to remove an item from a collection using the
RemoveAt method, I get a "Index was out of range. Must be non-negative and
less than the size of the collection. Parameter name: index" error even
tough I verify in debug that the collection count is equal to 1 and I try to RemoveAt(collec tion.count - 1) (so the index is non-negative and is less
than the size of the collection). And that error occurs if I try to remove
any index from the collection. On the other hand, on one specific page where I put only one collection in the session (but exactly the same logic and
code apply), eveything works fine. Can someone help me out?


Just for fun, try using Remove(collecti on[0]);
--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #2
On Mon, 12 Jul 2004 15:58:12 -0400, Alexandre Soares
<so*********@ho tmail.com> wrote:
Hi,

On some pages, I put a collection in the session, which uses the InProc
mode. On pages where the session is extensively used (many collections
are
put into it), whenever I try to remove an item from a collection using
the
RemoveAt method, I get a "Index was out of range. Must be non-negative
and
less than the size of the collection. Parameter name: index" error even
tough I verify in debug that the collection count is equal to 1 and I
try to
RemoveAt(collec tion.count - 1) (so the index is non-negative and is less
than the size of the collection). And that error occurs if I try to
remove
any index from the collection. On the other hand, on one specific page
where
I put only one collection in the session (but exactly the same logic and
code apply), eveything works fine. Can someone help me out?

Thank you very much!


try pulling the collection out into a local var, remove the item, then
reassign the session var. i think i've seem problems like this when i
don't explictly reassign it....

but worth a try, and IMHO is actually a little cleaner approach (but i'm a
purist!)

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #3
That's actually what I am doing (pulling out the collection into a local
variable, removing the item and puting it back into the session :)

"Craig Deelsnyder" <cdeelsny@no_sp am_4_meyahoo.co m> a écrit dans le message
de news:op******** ******@web-1161d.webservic es.nrt...
On Mon, 12 Jul 2004 15:58:12 -0400, Alexandre Soares
<so*********@ho tmail.com> wrote:
Hi,

On some pages, I put a collection in the session, which uses the InProc
mode. On pages where the session is extensively used (many collections
are
put into it), whenever I try to remove an item from a collection using
the
RemoveAt method, I get a "Index was out of range. Must be non-negative
and
less than the size of the collection. Parameter name: index" error even
tough I verify in debug that the collection count is equal to 1 and I
try to
RemoveAt(collec tion.count - 1) (so the index is non-negative and is less
than the size of the collection). And that error occurs if I try to
remove
any index from the collection. On the other hand, on one specific page
where
I put only one collection in the session (but exactly the same logic and
code apply), eveything works fine. Can someone help me out?

Thank you very much!


try pulling the collection out into a local var, remove the item, then
reassign the session var. i think i've seem problems like this when i
don't explictly reassign it....

but worth a try, and IMHO is actually a little cleaner approach (but i'm a
purist!)

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 18 '05 #4
On Tue, 13 Jul 2004 08:30:28 -0400, Alexandre Soares
<so*********@ho tmail.com> wrote:
That's actually what I am doing (pulling out the collection into a local
variable, removing the item and puting it back into the session :)

"Craig Deelsnyder" <cdeelsny@no_sp am_4_meyahoo.co m> a écrit dans le
message
de news:op******** ******@web-1161d.webservic es.nrt...
On Mon, 12 Jul 2004 15:58:12 -0400, Alexandre Soares
<so*********@ho tmail.com> wrote:
> Hi,
>
> On some pages, I put a collection in the session, which uses the

InProc
> mode. On pages where the session is extensively used (many collections
> are
> put into it), whenever I try to remove an item from a collection using
> the
> RemoveAt method, I get a "Index was out of range. Must be non-negative
> and
> less than the size of the collection. Parameter name: index" error

even
> tough I verify in debug that the collection count is equal to 1 and I
> try to
> RemoveAt(collec tion.count - 1) (so the index is non-negative and is

less
> than the size of the collection). And that error occurs if I try to
> remove
> any index from the collection. On the other hand, on one specific page
> where
> I put only one collection in the session (but exactly the same logic

and
> code apply), eveything works fine. Can someone help me out?
>
> Thank you very much!
>
>


try pulling the collection out into a local var, remove the item, then
reassign the session var. i think i've seem problems like this when i
don't explictly reassign it....

but worth a try, and IMHO is actually a little cleaner approach (but
i'm a
purist!)

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET



ah, wasn't sure...I have seen people act directly on the Session object,
which I'm not saying that's incorrect (dunno for sure)....

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #5

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

Similar topics

5
3565
by: mvr | last post by:
Hi all IIS 5.0, ASP, and https:// I have "DataEntrypage.asp" which is a data entry page(about 250 data elements includes text boxes, radio buttons, check boxes, drop down boxes etc). After the data validation through javascript(form.action = "ProcessData.asp" )I post this page to "ProcessData.asp" which process all
2
1488
by: Gus Gustafson | last post by:
I set ndi in a repost of a page: window.location.href= '../Test/test.aspx' + '?ndi=' + theform.domain_SELECT.options.selectedIndex; In the test.aspx.cs code-behind, I test if ndi is set as if ( Request != null )
0
244
by: Hazzard | last post by:
I am trying to figure out how to add an additional value to a querystring collection so that when I click on a datagrid cell, there will be a key to distinguish it from another column's functionality. I have Edit and Delete columns that each contain the ColumnID for the record I want to either edit, or delete. When I pull the item of the collection on the target page's page_load event, I will be able to either invoke a delete or an edit...
66
4148
by: Cor | last post by:
Hi, I start a new thread about a discussion from yesterday (or for some of us this morning). It was a not so nice discussion about dynamically removing controls from a panel or what ever. It started by an example from me, that was far from complete and with typing errors, but basically it had the meaning to show that removing controls reversible was the nicest method. This was a lets say conclusion (but what is that in a newsgroup) in a...
5
1134
by: vsr | last post by:
is there any way to remove some information from trace, tracing by default displays session , application variables, but i need to remove these two from trace.can any let me know how can i do it?
6
1792
by: Joe | last post by:
Hello All: I have a webform (WebForm1.aspx) that retrieves a value from a database (_formSessionId) the first time that it is posted. After the user filles in the form, he/she clicks a Button server control that ultimately redirects him/her to WebForm2.aspx . I need to persist the value of _formSessionId between the initial post and the postback (after the Button control is clicked). I would like to add the value to the QueryString...
6
6116
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or more minutes. 'REMOVE DUBLICATED VALUE FROM ARRAY +++++++++++++++++ Dim col As New Scripting.Dictionary Dim ii As Integer = 0
8
1997
by: Michael Schwarz | last post by:
Hi, I have a problem where I have two requests (i.e. two different windows that are using the same session) that are accessing the session collection. The requests will need more time on the server, but I get the problem that the two sessions are not getting updated values from each requests. Is this by design or is there any solution to do this? -- Best regards | Schöne Grüße
9
3713
by: dotnetismylife | last post by:
Hi all, I have a question, in the following code: using System; using System.Diagnostics; namespace ConsoleApplication1 { class TestClass {
0
10435
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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
10163
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
10000
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...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6779
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();...
1
4113
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
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.