none
Visual Studio 2005 debugging problems

    Question

  •    I am trying to develop an interface for Intermec's labelshop 6.12.  Intermec supplies a sample interface called frstprgm that was written in VB 6.0.  I have tried to convert this file to a Visual Studio 2005 project but I am receiving an error when trying to debug.  This portion of the code is the Dialog.Designer.vb.  The error is on the first line of code and it flags "Dialog" and gives an "InvalidOperationException was unhandled An error occurred creating the form. See Exception.InnerException for details.  The error is: Object reference not set to an instance of an object."  I was only able to include a portion of the code because it was too large.  Any help or ideas would be greatly appreciated.

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> Partial Class Dialog  
    #Region "Windows Form Designer generated code "  
        <System.Diagnostics.DebuggerNonUserCode()> Public Sub New()  
            MyBase.New()  
            'This call is required by the Windows Form Designer.  
            InitializeComponent()  
        End Sub  
        'Form overrides dispose to clean up the component list.  
        <System.Diagnostics.DebuggerNonUserCode()> Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)  
            If Disposing Then  
                If Not components Is Nothing Then  
                    components.Dispose()  
                End If  
            End If  
            MyBase.Dispose(Disposing)  
        End Sub  
        'Required by the Windows Form Designer  
        Private components As System.ComponentModel.IContainer  
        Public ToolTip1 As System.Windows.Forms.ToolTip  
        Public CommonDialog1Open As System.Windows.Forms.OpenFileDialog  
        Public CommonDialog1Save As System.Windows.Forms.SaveFileDialog  
        Public CommonDialog1Font As System.Windows.Forms.FontDialog  
        Public CommonDialog1Color As System.Windows.Forms.ColorDialog  
        Public CommonDialog1Print As System.Windows.Forms.PrintDialog  
        Public WithEvents cmdQuit As System.Windows.Forms.Button  
        Public WithEvents cmdPreviousRecord As System.Windows.Forms.Button  
        Public WithEvents Preview2 As System.Windows.Forms.Button  
        Public WithEvents cmdLastRecord As System.Windows.Forms.Button  
        Public WithEvents cmdNextRecord As System.Windows.Forms.Button  
        Public WithEvents cmdFirstRecord As System.Windows.Forms.Button  
        Public WithEvents Frame6 As System.Windows.Forms.GroupBox  
        Public WithEvents OptLppx As System.Windows.Forms.RadioButton  
        Public WithEvents OptNoControl As System.Windows.Forms.RadioButton  
        Public WithEvents Frame5 As System.Windows.Forms.GroupBox  
        Public WithEvents cmdMerge As System.Windows.Forms.Button  
        Public WithEvents cmdPrint As System.Windows.Forms.Button  
        Public WithEvents cmdAddPrinters As System.Windows.Forms.Button  
        Public WithEvents txtQuantity As System.Windows.Forms.TextBox  
        Public WithEvents Label3 As System.Windows.Forms.Label  
        Public WithEvents Frame4 As System.Windows.Forms.GroupBox  
        Public WithEvents cmdFiller As System.Windows.Forms.Button  
        Public WithEvents lstVariables As System.Windows.Forms.ListBox  
        Public WithEvents cmdVariables As System.Windows.Forms.Button  
        Public WithEvents Frame3 As System.Windows.Forms.GroupBox  
        Public WithEvents cmdCloseQuery As System.Windows.Forms.Button  
        Public WithEvents txtQueryname As System.Windows.Forms.TextBox  
        Public WithEvents cmdOpenQuery As System.Windows.Forms.Button  
        Public WithEvents Label2 As System.Windows.Forms.Label  
        Public WithEvents Frame2 As System.Windows.Forms.GroupBox  
        Public WithEvents cmdPreview As System.Windows.Forms.Button  
        Public WithEvents cmdOpen As System.Windows.Forms.Button  
        Public WithEvents cmdSave As System.Windows.Forms.Button  
        Public WithEvents txtFilename As System.Windows.Forms.TextBox  
        Public WithEvents Label1 As System.Windows.Forms.Label  
        Public WithEvents Frame1 As System.Windows.Forms.GroupBox  
        'NOTE: The following procedure is required by the Windows Form Designer  
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.  
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()  
            Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Dialog))  
            Me.components = New System.ComponentModel.Container()  
            Me.ToolTip1 = New System.Windows.Forms.ToolTip(components)  
            Me.CommonDialog1Open = New System.Windows.Forms.OpenFileDialog  
            Me.CommonDialog1Save = New System.Windows.Forms.SaveFileDialog  
            Me.CommonDialog1Font = New System.Windows.Forms.FontDialog  
            Me.CommonDialog1Color = New System.Windows.Forms.ColorDialog  
            Me.CommonDialog1Print = New System.Windows.Forms.PrintDialog  
            Me.cmdQuit = New System.Windows.Forms.Button  
            Me.cmdPreviousRecord = New System.Windows.Forms.Button 
    Monday, October 27, 2008 9:25 PM

All replies

  • Hi

    Since you only include a portion of the code, we are not quite clear whether "MyBase" is included, too.
    Besides, does class "Dialog" is inherited from any other classes or interfaces?

    Usually, this error happens often because there might be a variable which has not set to an instance of an object when we use it. One of the solutions is might to find the object which might set to a null reference and then set it to a concret instance.
    And here, I doubt that the call of the method "MyBase.New()" might not be proper, in fact, we don't quite clear the method's code, could you please provide us with more information?

    Hope that can help you and may you have a good day!!

    Regards,


    Roahn
    Tuesday, November 04, 2008 6:50 AM
  • Is there a way I can zip the entire program and send it to you as an attachment in an email?  The actual code behind file for the application is named Dialog.vb and under this is the other file that I included a portion of on the previous post, Dialog.Designer.vb.  When double clicking the form, The code for Dialog.vb is as follows:

    Option Strict Off

    Option Explicit On

    Friend Class Dialog

    Inherits System.Windows.Forms.Form

    Dim MyApp As LabelManager2.Application

    Dim MyDoc As LabelManager2.Document

    Dim MyVars As LabelManager2.Variables

    Private Sub Dialog_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

    Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

    MyApp = New LabelManager2.Application

    MyApp.Visible = False

    Me.Cursor = System.Windows.Forms.Cursors.Default

    End Sub

    Private Sub Dialog_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

    UnloadLppx()

    frmPrvw.Close()

    End Sub

    ' *********** BUTTONS MANAGMENT *********

    Private Sub cmdOpen_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOpen.Click

    If SelectFile("lab (*.lab)|*.lab", 1) Then

    'UPGRADE_NOTE: Variable CommonDialog1 was renamed CommonDialog1Open. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="94ADAC4D-C65D-414F-A061-8FDC6B83C5EC"'

    txtFilename.Text = CommonDialog1Open.FileName

    Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

    MyDoc = MyApp.Documents.Open(txtFilename.Text)

    Me.Cursor = System.Windows.Forms.Cursors.Default

    End If

    End Sub

    Private Sub cmdSave_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSave.Click

    If SelectFile("lab (*.lab)|*.lab", 2) Then

    'UPGRADE_NOTE: Variable CommonDialog1 was renamed CommonDialog1Open. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="94ADAC4D-C65D-414F-A061-8FDC6B83C5EC"'

    txtFilename.Text = CommonDialog1Open.FileName

    MyDoc.SaveAs(txtFilename.Text)

    End If

    End Sub

    Private Sub cmdOpenQuery_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOpenQuery.Click

    If SelectFile("csq (*.csq)|*.csq", 1) Then

    'UPGRADE_NOTE: Variable CommonDialog1 was renamed CommonDialog1Open. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="94ADAC4D-C65D-414F-A061-8FDC6B83C5EC"'

    txtQueryname.Text = CommonDialog1Open.FileName

    Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

    MyDoc.Database.OpenQuery(txtQueryname.Text)

    Me.Cursor = System.Windows.Forms.Cursors.Default

    End If

    End Sub

    Private Sub cmdCloseQuery_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCloseQuery.Click

    MyDoc.Database.Close()

    txtQueryname.Text = ""

    lstVariables.Items.Clear()

    End Sub

    Private Sub cmdPreview_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPreview.Click

    Preview()

    End Sub

    Private Sub cmdVariables_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdVariables.Click

    Dim var As LabelManager2.Variables

    lstVariables.Items.Clear()

    MyVars = MyDoc.Variables

    'For Each var In vars

    lstVariables.Items.Add(var.Name)

    'Next var

    End Sub

    Private Sub cmdFiller_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFiller.Click

    MyApp.Dialogs._Item(LabelManager2.enumDialogType.lppxFormDialog).Show()

    End Sub

    Private Sub cmdAddPrinters_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdAddPrinters.Click

    MyApp.Dialogs._Item(LabelManager2.enumDialogType.lppxPrinterSelectDialog).Show()

    End Sub

    Private Sub cmdPrint_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPrint.Click

    MyDoc.PrintLabel(CInt(txtQuantity.Text))

    MyDoc.FormFeed()

    End Sub

    Private Sub cmdMerge_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdMerge.Click

    MyDoc.Merge(1)

    End Sub

    'UPGRADE_WARNING: Event OptNoControl.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'

    Private Sub OptNoControl_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptNoControl.CheckedChanged

    If eventSender.Checked Then

    MyApp.Visible = False

    End If

    End Sub

    'UPGRADE_WARNING: Event OptLppx.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'

    Private Sub OptLppx_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptLppx.CheckedChanged

    If eventSender.Checked Then

    MyApp.Visible = True

    'sample of ActiveX error management:

    Dim Errornum As Integer

    Dim ErrorMsg As String

    Errornum = MyApp.GetLastError

    ErrorMsg = MyApp.ErrorMessage(Errornum)

    If Errornum <> 0 Then

    MsgBox(ErrorMsg, MsgBoxStyle.Critical, "Error #" & Errornum)

    End If

    'sample end here

    End If

    End Sub

    Private Sub cmdFirstRecord_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFirstRecord.Click

    MyDoc.Database.MoveFirst()

    If frmPrvw.Visible Then Preview()

    End Sub

    Private Sub cmdPreviousRecord_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPreviousRecord.Click

    MyDoc.Database.MovePrevious()

    If frmPrvw.Visible Then Preview()

    End Sub

    Private Sub cmdNextRecord_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNextRecord.Click

    MyDoc.Database.MoveNext()

    If frmPrvw.Visible Then Preview()

    End Sub

    Private Sub cmdLastRecord_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLastRecord.Click

    MyDoc.Database.MoveLast()

    If frmPrvw.Visible Then Preview()

    End Sub

    Private Sub Preview2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Preview2.Click

    Preview()

    End Sub

    '**** Procedure & Function ****

    Sub Preview()

    MyDoc.CopyToClipboard()

    'UPGRADE_ISSUE: Load statement is not supported. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="B530EFF2-3132-48F8-B8BC-D88AF543D321"'

    'RaiseEvent Load(frmPrvw)

    'UPGRADE_ISSUE: Constant vbCFMetafile was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="55B59875-9A95-4B71-9D6A-7C294BF7139D"'

    frmPrvw.imgPreview.Image = My.Computer.Clipboard.GetImage()

    frmPrvw.Show()

    End Sub

    Private Function SelectFile(ByVal filters As String, ByVal actioncode As Integer) As Boolean

    Dim s As String

    s = Mid(filters, InStrRev(filters, "|") + 1)

    On Error Resume Next

    'UPGRADE_WARNING: CommonDialog variable was not upgraded Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="671167DC-EA81-475D-B690-7A40C7BF4A23"'

    With CommonDialog1Open

    'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'

    .Filter = filters

    .FileName = s

    'UPGRADE_ISSUE: MSComDlg.CommonDialog property CommonDialog1.Action was not upgraded. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'

    '.Action = actioncode()

    'Dialog box is displaying

    '...

    'Dialog box is closed

    If Err.Number = 0 Then

    SelectFile = True

    End If

    End With

    End Function

    Private Sub cmdQuit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdQuit.Click

    Me.Close()

    End Sub

    Private Sub UnloadLppx()

    MyApp.Documents.CloseAll(False)

    MyApp.Quit()

    'UPGRADE_NOTE: Object MyApp may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'

    MyApp = Nothing

    End Sub

    Private Sub Frame2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Frame2.Enter

    End Sub

    End Class

    Thursday, November 06, 2008 4:12 PM
  • Quick question: are you developing on the same machine as VB6?
    Thanks,
    Corey Furman
    Code Slabs
    ______________________________________________________
    Please mark posts as answer or helpful when they are.
    Thursday, November 06, 2008 7:24 PM