Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 14th, 2007, 09:24 AM
Authorized User
 
Join Date: Feb 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Try...Catch

I am writing code in VB from Visual Studio 2005 Standard Edition. I find it really nice that a Try...Catch exception actually provides the line number in which the exception occurred.

I wanted to know if the line number was also displayed in a compiled, excuse me, a published program. I created a simple program with a form and no controls. The Form_Load procedure has an intentional error.

Here is the code.
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim x As Long = 64000
        MessageBox.Show(x.ToString)
        Try
            Dim y = CShort(x)
            MessageBox.Show(y.ToString)
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub


When I run the program in the VB environment it works fine and tells me there is an error in Line 7 {Dim y = CShort(x)}.

Unfortunately, after I publish the program and run it, I get an Unhandled exception...
StartIndex cannot be less than zero.
Parameter name: startIndex

I have not been able to find any information on what this (startIndex) is, where it is, or what to do about it. Any help would be appreciated.

Thanks, Lowell

 
Old July 14th, 2007, 12:06 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

My understanding is:

When you are building an application in Visual Studio and the application is compiled, .pdb files are created along side the application's assemblies. These .pdb files link the execution points in the MSIL assembly to the lines of code in the code files. They form the bridge. If you remove these, the program will still run, but the runtime will no longer be able to link a execution point in the assembly back to the source code. This introduces some uncertainty to the debugging process for sure.

I'm curious why you say "...compiled, excuse me, a published program". What do you see as the difference.

Have you tried googling the error message to see if you can find something on it? It almost seems that it is coming from somewhere else as it doesn't appear to relate to the code sample you posted.

-Peter
 
Old July 22nd, 2007, 09:31 PM
Authorized User
 
Join Date: Feb 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Googling the error message only told me I was not alone in not understanding this error.

Why "...compiled, excuse me, a published program". Because Microsoft decided to change the name. I really don't see a difference.

Thanks, Lowell



 
Old July 23rd, 2007, 06:35 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'm curious as to what has made you believe that Microsoft has changed the name? I have not heard of such change. I have been compiling lots of .NET code for the last several years, but not never "published" (in Microsoft parlance) any of it, however I have several production web sites running the code that I compiled.

My view is that Microsoft uses the term "publish" as a substitute for "deploy". I guess, technically deploying something implies you are sending it somewhere where as publishing would imply that you are making something publicly available.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Try/Catch/Finally rohit.sharma C# 2 January 12th, 2007 11:44 PM
catch the alerts catchrohith Classic ASP Basics 1 October 26th, 2006 06:39 AM
Try Catch not working?? dparsons ASP.NET 1.0 and 1.1 Professional 3 September 18th, 2006 06:54 PM
Try and Catch? mujju PHP How-To 2 January 20th, 2005 12:27 PM
How to catch error. lancet2003 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 December 3rd, 2003 02:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.