Index was outside the bounds of the array

A

Antoine

I can't work out what is causing this problem. Can anyone suggest what the
typical causes beyond the obvious might be? Could you get it with datasets?
Maybe I should run in debug mode and test certain bits of code for
"erroneous" and unpredictable values?
Many thanks!

"An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the exception
can be identified using the exception stack trace below.

Stack Trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Array.InternalGetValue(Int32 index1, Int32 index2, Int32 index3)
+0
System.Array.GetValue(Int32 index) +32
Microsoft.VisualBasic.CompilerServices.LateBinding.LateIndexGet(Object o,
Object[] args, String[] paramnames) +187
sharedcal.ShareCal.o() +655
sharedcal.ShareCal.Page_Load(Object o, EventArgs e) +799
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
 
C

Cor Ligthert

Antoine,

The first thing you can do is set in top of your program file (vb code)

Option Strict On

Maybe than you see some errors.

I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

Antoine said:
I can't work out what is causing this problem. Can anyone suggest what the
typical causes beyond the obvious might be? Could you get it with
datasets?
Maybe I should run in debug mode and test certain bits of code for
"erroneous" and unpredictable values?

Yes, you should to that. Without seeing some code it's impossble to solve
the problem.
 
A

Antoine

Cor Ligthert said:
Antoine,

The first thing you can do is set in top of your program file (vb code)

Option Strict On

Maybe than you see some errors.

I hope this helps?

Cor

Thank you. But It needs to work in a remote scenario, without the debugger.
Would this have any impact ?
I sent the PDB to one guy who has the problem. However unlike my IIS test
virtual directory, which reveals linenumbers when it fails - his didn't.
Do you think the above might help with that, if I recompiled with it on (and
then did my dotfuscate) ?

Otherwise I am going to have to try putting in something like individual
debug writelines at various points in the code, so it can hopefully trap
where roughly its at when it fails. But I have never done this, because I
had some problems with it recognising the debug.writeln command even after I
explicitly used imports system.diagnostics.debug etc.

The thing is, other that referring to rows within a dataset via an integer
value, I don't know of anywhere else it might get this error as they are
pretty bulletproof and trapped ranges eg something like

dim string test as string()
string(1) = "test1"
string(2) = "test2"
for i = 0 to 2
if othervalue = i then otherstring = string(i)

end for
 
A

Antoine

Herfried K. Wagner said:
Yes, you should to that. Without seeing some code it's impossble to solve
the problem.

Thanks. Is there any easy way (using vb.net and asp.net technolgies) that I
could add trace of the problem to my project when debugging, eg even a rough
line would help? I tried sending the pdb to a person with the problem but it
did not reveal the line during debug, just the same error as before.
 
A

Antoine

Herfried K. Wagner said:
Yes, you should to that. Without seeing some code it's impossble to solve
the problem.

I should add that part of the frustration is I can't replicate it ( well I
did for a very short interval when ran as a runtime version from a demo
virtual directory, but then recompiled again and it went away, but the guys
still say they have it though my deployments dont).

I couldn't debug also without slightly modifiying code because I have been
having SOAP problems so have to alter the code for a specific username when
in the debugger, as opposed to during the demo virtual test (which might be
an Active Directory problem). A wierd little issue but when its compiled it
uses the default credentials anyway.

So frustratingly, even though it happened for an inteval for myself, I was
unable to replicate further and reprudce it for debugging and the build is
currently ok now when run (though not at his site). So I really need some
other debug techniques I havent tried, that will work remotely.
Thanks

Antoine
 
H

Herfried K. Wagner [MVP]

Antoine said:
The thing is, other that referring to rows within a dataset via an integer
value, I don't know of anywhere else it might get this error as they are
pretty bulletproof and trapped ranges eg something like

dim string test as string()
string(1) = "test1"
string(2) = "test2"
for i = 0 to 2
if othervalue = i then otherstring = string(i)

end for

This code doesn't even compile!

\\\
Dim Test() As String = {"test1", "test2"}
For i As Integer = 0 To Test.Length - 1
If OtherValue = i Then
OtherString = Test(i)
End If
Next i
///
 
A

Antoine

Sorry as I indicated it was an example and off the top of my head the best I
could do to approximate what I am doing. I am only new to VB.NET.
You obviously have the idea. That is not the issue, as my code does compile
but I dont have it to hand. Its a matter of what could it be, since the sort
of example below could not possible cause this error could it?
Thanks
 
A

Antoine

Thanks. Actually that was an approximation of the code, so you are right its
not correct, but thats not my issue. My issue is that written correctly
(like the code which I do not have to hand) surely it would NEVER cause this
issue and therefore I was wondering what else might cause it unless there is
any way that certain conditions could cause it to fail ?

I have just got turned on to tracing - this is an excellent guide. I may try
that.

http://www.informit.com/guides/content.asp?g=dotnet&seqNum=217
 
A

Antoine

Dim actvtypearray(3) As String
actvtypearray(0) = "Phone Call"
actvtypearray(1) = "Appointment"
actvtypearray(2) = "Task"

Dim intcounter2 As Integer
For intcounter2 = 0 To 2
If
datasettest.Tables("result").Rows(intCounter).Item("item1") =
actvtypearray(intcounter2) Then
dataRow("link") =
Convert.ToString(intcounter2)
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top