Is anyone else having problems with the Random class
I am using the following code in a 3d graphics application which models erosion on a landscape:
nOffset = rnd.Next(NUM_DIRECTIONS);
if (nOffset == NUM_DIRECTIONS)
throw new ApplicationException("This shouldn't Happen");
and guess what, the exception is thrown. Not very often. I am running
at around 20fps with the above code being called around 500,000 times
per frame (don't you just love modern computer speeds!). It happens
after about sixty seconds, but varies since I don't seed the random
number.
By my calculations that makes it once every 600 million times through the code.
The docco clearly states that Random.Next() should return a value less than the parameter.
Anyone else seen this bug in .Net 2.0. If so, anyone know if and when it will be fixed.

Random Class
TomAStraw
With NUM_DIRECTIONS set to 3, 10 and 500, I’ve run your that code about 25 billion times (each) and have yet to see an error.
I hope you’ll understand if I suspect things other than the framework to be the cause of your issue, in large part because such an obvious error would likely have been caught and fixed previously.
Any chance that your processor is over clocked It is not uncommon for an over clocked processor to make mathematical (and other) errors that could manifest themselves as something like this.
Vimm
Moved to “Common Language Runtime”.
Better chances to find some help here.