Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exception occurs launching .exe but no problem in IDE

Posted on 2014-02-24
2
Medium Priority
?
152 Views
Last Modified: 2014-02-24
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?
0
Comment
Question by:TimHudspith
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39882170
Where in your form does that line of code live? It could be an initialization issue, where you are trying to access a subitem before they have all been loaded.

Daft question, but worth checking - do you definitely have 5 subitems, rather than 1 top-level item with 4 subitems?
0
 

Author Comment

by:TimHudspith
ID: 39882613
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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question