PDA

View Full Version : Help With Application.Run(Form)


M_Timoney
01-22-2004, 11:39 AM
i have the following code on a form:

-----------------------------
AvEquipment.DataSource = p.Game.ShipEquipment;
-----------------------------

this code runs perfectly on it's own but when called in the following method:

-----------------------------
forms.Push(new ShipDesigner(p));
Application.Run(((Form)forms.Peek()));
-----------------------------

the creation works fine but the application.run(form) throws

-----------------------------
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll

Additional information: Index was outside the bounds of the array.
-----------------------------

if i change the code to:

-----------------------------
AvEquipment.DataSource = new ArrayList(new int[]{1,2,3,4,5,6,7,8,9,10});
-----------------------------
it works fine as well

as i don't understand why this happens i can't trace the problem

ps
the shipEquipment method is this

-----------------------------
public ArrayList ShipEquipment{
get{return equiment;}
}
-----------------------------
and by inserting a break point and adding a watch

ArrayList a = p.Game.ShipEquipment;
shows
- a {Count=13} System.Collections.ArrayList
+ [0] {Game.Weapon} Game.Weapon
+ [1] {Game.Weapon} Game.Weapon
+ [2] {Game.Weapon} Game.Weapon
+ [3] {Game.Armour} Game.Armour
+ [4] {Game.Armour} Game.Armour
+ [5] {Game.Engine} Game.Engine
+ [6] {Game.Engine} Game.Engine
+ [7] {Game.Storage} Game.Storage
+ [8] {Game.Storage} Game.Storage
+ [9] {Game.Other} Game.Other
+ [10] {Game.Other} Game.Other
+ [11] {Game.EW} Game.EW
+ [12] {Game.EW} Game.EW

i've also attached the code (All of it)