471,350 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

CLR bug?

Preamble.
Back in the .net 1.0 days I was very concerned about a CLR bug that I
encountered. I had an if-then-else clause and the thread did not enter either
the true or false statements. After an upgrade to .net 1.1 (suggested by
Microsoft that recognized this erroneous behaviour) the problem were
resolved. Howver, as it was the first time ever I had expericed a
compiler/I.L. execution (whatever??) error, I lost a little confidence in the
compilation/i.l execution in .net. As a former c++ programmer I had learned
by experience that I, as the programmer, always were the origin of unexpected
behaviour - but this experience changed that - and today, a new weird thing
is happening. Please help:
foreach (ListViewItem lvi in this.listViewToDoList.Items)
{
Work wp = (Work)lvi.Tag;
lvi.ImageIndex = GetWaypointImageIndex(wp);
lvi.Checked = wp.Done;
lvi.SubItems[2].Text = wp.Modified;
}

The weird thing is that the collection only contains 2 elements!, the Count
field is equal to 2. But it runs thru the loop a third time and throws an
exception that lvi is null!?!. How is that possible?

Best regards
Jesper

Jun 27 '08 #1
1 938
On May 14, 1:46 pm, Jesper, Denmark
<JesperDenm...@discussions.microsoft.comwrote:
Preamble.
Back in the .net 1.0 days I was very concerned about a CLR bug that I
encountered. I had an if-then-else clause and the thread did not enter either
the true or false statements. After an upgrade to .net 1.1 (suggested by
Microsoft that recognized this erroneous behaviour) the problem were
resolved. Howver, as it was the first time ever I had expericed a
compiler/I.L. execution (whatever??) error, I lost a little confidence in the
compilation/i.l execution in .net. As a former c++ programmer I had learned
by experience that I, as the programmer, always were the origin of unexpected
behaviour
You never, ever ran into a compiler or library bug? You're lucky :)
- but this experience changed that - and today, a new weird thing
is happening. Please help:

foreach (ListViewItem lvi in this.listViewToDoList.Items)
{
Work wp = (Work)lvi.Tag;
lvi.ImageIndex = GetWaypointImageIndex(wp);
lvi.Checked = wp.Done;
lvi.SubItems[2].Text = wp.Modified;
}

The weird thing is that the collection only contains 2 elements!, the Count
field is equal to 2. But it runs thru the loop a third time and throws an
exception that lvi is null!?!. How is that possible?
Pretty hard to say without a way of reproducing it (although I think
it's more likely to be a framework bug than a CLR bug, if indeed
there's a bug at all).

Could you post a short but complete program which demonstrates the
problem?

See http://pobox.com/~skeet/csharp/complete.html for what I mean by
that.

Jon
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.