473,666 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange Errors

I'm having my site email errors to me until I get things as stable as
possible. Occasionally, I get an error that I just cannot see how it could
ever happen. I enabled debugging on the live site so that I could get
line-number information. But I'm still at a loss.

I've posted an error below, and the code below that. Somehow,
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex] is causing an
ArgumentOutOfRa ngeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.
>>>>ERROR <<<<<
System.Web.Http UnhandledExcept ion: Exception of type
'System.Web.Htt pUnhandledExcep tion' was thrown. --->
System.Argument OutOfRangeExcep tion: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collecti ons.ArrayList.g et_Item(Int32 index)
at System.Web.UI.W ebControls.Data KeyArray.get_It em(Int32 index)
at ASP.Workouts.bt nSubstitute_Cli ck(Object sender, ImageClickEvent Args e)
in d:\Inetpub\medi corpmap\Control s\Workouts.ascx :line 155
at System.Web.UI.W ebControls.Imag eButton.OnClick (ImageClickEven tArgs e)
at System.Web.UI.W ebControls.Imag eButton.RaisePo stBackEvent(Str ing
eventArgument)
at
System.Web.UI.W ebControls.Imag eButton.System. Web.UI.IPostBac kEventHandler.R aisePostBackEve nt(String
eventArgument)
at System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
at System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.P age.HandleError (Exception e)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est()
at System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context)
at System.Web.UI.P age.ProcessRequ est(HttpContext context)
at ASP.trainer_wor kouts_aspx.Proc essRequest(Http Context context) in
c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary ASP.NET
Files\root\f2d4 905b\94fa3b3c\A pp_Web_amhr_qtk .2.cs:line 0
at
System.Web.Http Application.Cal lHandlerExecuti onStep.System.W eb.HttpApplicat ion.IExecutionS tep.Execute()
at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean&
completedSynchr onously)
>>>>CODE <<<<<
if (ddlWorkouts.It ems.Count == 0)
{
ErrorMessage1.S etError("You must first create one or more workouts before
you can exchange workout items.");
}
else if (grdWorkout.Sel ectedIndex == -1)
{
ErrorMessage1.S etError("You must first select an activity in the workout
before you can exchange it.");
}
else
{
EncryptedQueryS tring queries = new EncryptedQueryS tring();
queries["UserID"] = UserID.ToString ();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.Sel ectedValue;
queries["WorkoutDetailI D"] =
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex].Value.ToString (); // <=====
LINE 155
Response.Redire ct(String.Forma t("{0}?data={1} ", SubstituteItemU rl,
queries), true);
}

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Jun 27 '08 #1
2 1328
You tested for -1 on selectedindex, you have not tested for the validity of
the datakeys collection which is where the error is coming from. What you
need is this:

if(grdWorkout.D ataKeys.Length 0)
queries["WorkoutDetailI D"] =
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex].Value.ToString ();

The datakeys collection holds keys relating to the records in the bound
control. However, the framework does not explicitly guarantee that these
keys will available when you need them. There is only a reasonable
expectation that the keys will be available. You must test the collection
before you use it - test and load pattern.

This isn't a common occurrence, you will likely hit this every once in a
while and typically while the site is under heavy load. I suspect that this
is related to a locked collection in the framework at the moment of access
but that's just a wild guess based on similar occurrences with collections.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:#Q******** ******@TK2MSFTN GP04.phx.gbl...
I'm having my site email errors to me until I get things as stable as
possible. Occasionally, I get an error that I just cannot see how it could
ever happen. I enabled debugging on the live site so that I could get
line-number information. But I'm still at a loss.

I've posted an error below, and the code below that. Somehow,
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex] is causing an
ArgumentOutOfRa ngeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.
>>>>>ERROR <<<<<

System.Web.Http UnhandledExcept ion: Exception of type
'System.Web.Htt pUnhandledExcep tion' was thrown. --->
System.Argument OutOfRangeExcep tion: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collecti ons.ArrayList.g et_Item(Int32 index)
at System.Web.UI.W ebControls.Data KeyArray.get_It em(Int32 index)
at ASP.Workouts.bt nSubstitute_Cli ck(Object sender, ImageClickEvent Args
e) in d:\Inetpub\medi corpmap\Control s\Workouts.ascx :line 155
at System.Web.UI.W ebControls.Imag eButton.OnClick (ImageClickEven tArgs e)
at System.Web.UI.W ebControls.Imag eButton.RaisePo stBackEvent(Str ing
eventArgument)
at
System.Web.UI.W ebControls.Imag eButton.System. Web.UI.IPostBac kEventHandler.R aisePostBackEve nt(String
eventArgument)
at System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
at System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.P age.HandleError (Exception e)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est()
at System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context)
at System.Web.UI.P age.ProcessRequ est(HttpContext context)
at ASP.trainer_wor kouts_aspx.Proc essRequest(Http Context context) in
c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary ASP.NET
Files\root\f2d4 905b\94fa3b3c\A pp_Web_amhr_qtk .2.cs:line 0
at
System.Web.Http Application.Cal lHandlerExecuti onStep.System.W eb.HttpApplicat ion.IExecutionS tep.Execute()
at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean&
completedSynchr onously)
>>>>>CODE <<<<<

if (ddlWorkouts.It ems.Count == 0)
{
ErrorMessage1.S etError("You must first create one or more workouts
before you can exchange workout items.");
}
else if (grdWorkout.Sel ectedIndex == -1)
{
ErrorMessage1.S etError("You must first select an activity in the workout
before you can exchange it.");
}
else
{
EncryptedQueryS tring queries = new EncryptedQueryS tring();
queries["UserID"] = UserID.ToString ();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.Sel ectedValue;
queries["WorkoutDetailI D"] =
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex].Value.ToString (); // <=====
LINE 155
Response.Redire ct(String.Forma t("{0}?data={1} ", SubstituteItemU rl,
queries), true);
}

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jun 27 '08 #2
Alvin,

Perhaps that's it. But if so then I don't get how DataKeys could ever be
empty. In my GridView, DataKeyNames is equal to one of the bound fields (the
primary key). Since this normally works, I know it's spelled correctly, etc.

Can you imagine any scenario where this would result in an empty DataKeys
collection?

And if this isn't odd enough, the user at the time is clear that he didn't
get any error. I wish I could explain a couple of things I'm curretnly
seeing.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Alvin Bruney [ASP.NET MVP]" <vapor dan using hot male spam filterwrote in
message news:0D******** *************** ***********@mic rosoft.com...
You tested for -1 on selectedindex, you have not tested for the validity
of the datakeys collection which is where the error is coming from. What
you need is this:

if(grdWorkout.D ataKeys.Length 0)
queries["WorkoutDetailI D"] =
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex].Value.ToString ();

The datakeys collection holds keys relating to the records in the bound
control. However, the framework does not explicitly guarantee that these
keys will available when you need them. There is only a reasonable
expectation that the keys will be available. You must test the collection
before you use it - test and load pattern.

This isn't a common occurrence, you will likely hit this every once in a
while and typically while the site is under heavy load. I suspect that
this is related to a locked collection in the framework at the moment of
access but that's just a wild guess based on similar occurrences with
collections.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:#Q******** ******@TK2MSFTN GP04.phx.gbl...
>I'm having my site email errors to me until I get things as stable as
possible. Occasionally, I get an error that I just cannot see how it
could ever happen. I enabled debugging on the live site so that I could
get line-number information. But I'm still at a loss.

I've posted an error below, and the code below that. Somehow,
grdWorkout.Dat aKeys[grdWorkout.Sele ctedIndex] is causing an
ArgumentOutOfR angeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.
>>>>>>ERROR <<<<<

System.Web.Htt pUnhandledExcep tion: Exception of type
'System.Web.Ht tpUnhandledExce ption' was thrown. --->
System.Argumen tOutOfRangeExce ption: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collecti ons.ArrayList.g et_Item(Int32 index)
at System.Web.UI.W ebControls.Data KeyArray.get_It em(Int32 index)
at ASP.Workouts.bt nSubstitute_Cli ck(Object sender, ImageClickEvent Args
e) in d:\Inetpub\medi corpmap\Control s\Workouts.ascx :line 155
at System.Web.UI.W ebControls.Imag eButton.OnClick (ImageClickEven tArgs e)
at System.Web.UI.W ebControls.Imag eButton.RaisePo stBackEvent(Str ing
eventArgumen t)
at
System.Web.UI. WebControls.Ima geButton.System .Web.UI.IPostBa ckEventHandler. RaisePostBackEv ent(String
eventArgumen t)
at System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceContro l, String eventArgument)
at System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesB eforeAsyncPoint , Boolean includeStagesAf terAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.P age.HandleError (Exception e)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesB eforeAsyncPoint , Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est(Boolean
includeStagesB eforeAsyncPoint , Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est()
at System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context)
at System.Web.UI.P age.ProcessRequ est(HttpContext context)
at ASP.trainer_wor kouts_aspx.Proc essRequest(Http Context context) in
c:\WINDOWS\Mic rosoft.NET\Fram ework\v2.0.5072 7\Temporary ASP.NET
Files\root\f2d 4905b\94fa3b3c\ App_Web_amhr_qt k.2.cs:line 0
at
System.Web.Htt pApplication.Ca llHandlerExecut ionStep.System. Web.HttpApplica tion.IExecution Step.Execute()
at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean&
completedSynch ronously)
>>>>>>CODE <<<<<

if (ddlWorkouts.It ems.Count == 0)
{
ErrorMessage1.S etError("You must first create one or more workouts
before you can exchange workout items.");
}
else if (grdWorkout.Sel ectedIndex == -1)
{
ErrorMessage1.S etError("You must first select an activity in the
workout before you can exchange it.");
}
else
{
EncryptedQueryS tring queries = new EncryptedQueryS tring();
queries["UserID"] = UserID.ToString ();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.Sel ectedValue;
queries["WorkoutDetailI D"] =
grdWorkout.Dat aKeys[grdWorkout.Sele ctedIndex].Value.ToString (); // <=====
LINE 155
Response.Redire ct(String.Forma t("{0}?data={1} ", SubstituteItemU rl,
queries), true);
}

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jun 27 '08 #3

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

Similar topics

6
3015
by: Eric Boutin | last post by:
Hi ! I have a strange problem with a std::ostringstream.. code : #include <sstream> /*...*/ std::ostringstream ss(); ss << "\"\"" << libpath << "\"\" \"\"" << argfilename << "\"\" \"\"" << outfilename << "\"\""; //line 75
3
1667
by: Jason | last post by:
I have two applications that I wrote that use asp and javascript source files. Recently both of these applications starting acting strange on my test box. Image icons will randomly stop showing up and any javascript that I use a src file with <script language="javascript" src="mytest.js"></script> ) returns random errors. Javascript on the page itself works fine. If I click f5 multiple times I will get different results. I am...
3
1757
by: Alfonso Morra | last post by:
I have some code that I am porting over from C. It is full of static functions and global variables. I have got around this by wrapping most of the code in a singleton object. However, I am findng that in my method definitions, I am having to fully scope the names of any other functions I am calling. I do not understand this. The clas declaration code look some thing like this: class A: public Singleton<A> { public:
12
1501
by: ishtar2020 | last post by:
Hi everybody I've been writing my very first application in Python and everything is running smoothly, except for a strange problem that pops up every once in a while. I'm sure is the kind of newbie thing every seasoned programmer knows. Sometimes a receive strange Syntax Errors from parts of code that worked perfectly minutes ago. What's even more puzzling is that those errors are pointed to another part of the module when I do some...
1
2438
by: Larax | last post by:
Alright, so here's the problem. I define a global variable in my script and then add methods/properties to it. Everything works great, no error in Javascript Console. But when I refresh site, several errors "variable is not defined" are displayed. What is more strange, the script is still working ! After each another refresh these errors are keep showing, only after I close site and open it again, these errors disappear, but only to next...
6
2357
by: robert | last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread. It is mainly with cookielib, but remember the problem also with other imports (e.g. urllib2 etc.). And again very often in all these cases where I get weired Python exceptions, the problem is around re-functions - usually during re.compile calls during import (see some of the exceptions below). But...
0
1048
by: AndreasJ.Mueller | last post by:
Hi Since we have moved our application (.NET 1.1) to a new server a few weeks ago we have seen in the event-logs multiple errors (which in itself is not my current problem, so I no Server.Transfer-Comments). What seems very strange is that each corresponding request shows as user agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4" even though the requests come from different IPs from all...
28
2078
by: charlie | last post by:
Hi, I found an article on informit.com that talks about C++ casts http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=285&rl=1 The strange thing is the author says the following code will *not* compile: double d=15.95; int n= static_cast<int(d);
11
1845
by: VijaKhara | last post by:
Hi all, I just write a very simple codes in C and vthere is a very strange bug which I cannot figure out why. The first loop is for v, and the second for k. There is no relationship between v and k but if I debug and watch the change of the variable after each command. When the sencond loop happends for k, the values of vs change and are set to be equal some values of k. Specifically, v is
5
2428
by: ioni | last post by:
Good day, fellows! I have a strange problem – at my site there is a flash strip, that loads data dynamically. It works fine (grabs data from the remote server and presents it), however in IE7 and its clones I encounter a strange problem where I can hear clicking sound non-stop (like the page is being reloaded non- stop), whereas the page is not reloading.
0
8440
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
8781
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
8550
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,...
1
6191
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
5662
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
4193
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...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
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.