Solved

Exception occurs launching .exe but no problem in IDE

Posted on 2014-02-24
2
147 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 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