Solved

Exception occurs launching .exe but no problem in IDE

Posted on 2014-02-24
2
143 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 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now