Link to home
Start Free TrialLog in
Avatar of TimHudspith
TimHudspith

asked on

Exception occurs launching .exe but no problem in IDE

I've created an application in VB.Net consisting of a couple of forms with listboxes and listviews showing lists of procedures and tables in a database. It works fine in debug mode in Visual Studio - I get no exceptions. But when I compile it and open the .exe it throws an exception when the second form opens, saying one of the parameter values is incorrect.

I have a line of code referencing the fifth subitem of a listitem in a listview:

.SubItems(5).Text = vbNullString

Open in new window


The error message is "InvalidArgument=Value of '5' is not valid for 'index'". But there are 5 subitems in the listview so what's wrong with it?
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TimHudspith
TimHudspith

ASKER

Yes, an initialisation issue. I subclassed the listview, and in that class I had an event that referenced the 5th subitem. I was instantiating this class before I had added in the listitems and subitems - with hindsight something I should have done as part of its constructor.

Still wondering why the debugger passed over it.