启动VB.Net WinForms程序时出现异常

时间:2014-09-29 18:32:27

标签: vb.net winforms exception

这个程序在我自己的机器上完美运行 - 程序总是在开发机上运行,​​对吧?

似乎在发布时感到不安。该应用程序有两种形式。默认表单检查是否有/ buy命令行参数,如果是,则通过显示另一个表单[formSB_Buy.Show()]并隐藏自身[Me.Hide()]切换到另一个表单

此应用程序仅从工具栏运行,该工具栏将/ sell或/ buy作为单个命令行参数。它只检查/购买,所以其他任何东西都只是继续使用默认表格。任何帮助解决此错误都将非常感激 - 我不知道该怎么做才能解决它。

例外:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Array.InternalGetReference(Void* elemRef, Int32 rank, Int32* pIndices)
   at System.Array.GetValue(Int32 index)
   at Microsoft.VisualBasic.CompilerServices.Symbols.Container.GetArrayValue(Object[] Indices)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.InternalLateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames, Boolean ReportErrors, ResolutionFailure& Failure, Boolean[] CopyBack)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateInvokeDefault(Object Instance, Object[] Arguments, String[] ArgumentNames, Boolean ReportErrors, Boolean[] CopyBack)
   at SellBuy.formSB_Sell.formSB_Sell_Shown(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnShown(EventArgs e)
   at System.Windows.Forms.Form.CallShownEvent()
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

守则:

Imports System.IO
Imports System.Xml
Imports System.Xml.Linq
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
Public Class formSB_Sell

Public Sub New()

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.

End Sub

Private Sub formSB_Sell_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
    Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
    If CommandLineArgs(0) = "/buy" Then
        formSB_Buy.Show()
        Me.Hide()
    Else
        Dim GMResult As String
        Dim wholeline As String = Nothing
        Dim arTextlines As Array
        Dim arLinefields As Array
        ' Load the arTextlines array with the result of the profiles request
        GMResult = GetMacro("&profiles.schwab..4")
        'TextBox129.Text = GMResult
        arTextlines = GMResult.Split(vbNewLine)
        ' Load the arLinefields array with the field data of the current arTextline
        For x = 0 To arTextlines.Length - 1
            arLinefields = Split(arTextlines(x), vbTab)
            For y = 0 To arLinefields.Length - 1
                wholeline = wholeline & Trim(arLinefields(y)) & " : "
            Next y
            Me.comboSBSell_ClientName.Items.Add(arLinefields(1) & " " & arLinefields(3))
            wholeline = Nothing
        Next x
        Me.comboSBSell_ClientName.SelectedIndex = 0
    End If
End Sub

0 个答案:

没有答案