System.InvalidOperationException: 'An error occurred creating the form

0

Upon trying to run/debug code of a WindowsForm I run into the following exception:

System.InvalidOperationException HResult=0x80131509 Message=An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. Source=Automated SoundPower Testing StackTrace: at Automated_SoundPower_Testing.My.MyProject.MyForms.Create__Instance__[T](T Instance) in :line 190 at Automated_SoundPower_Testing.My.MyProject.MyForms.get_Form1() at Automated_SoundPower_Testing.My.MyApplication.OnCreateMainForm() in C:\Users\M0110823\source\repos\Automated SoundPower Testing\My Project\Application.Designer.vb:line 35 at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at Automated_SoundPower_Testing.My.MyApplication.Main(String[] Args) in :line 81

Inner Exception 1: NullReferenceException: Object reference not set to an instance of an object."

This exception references:

Me.MainForm = Global.Automated_SoundPower_Testing.Form1

I'm thinking this could possibly be due to the fact that I am trying to call Me.Mainform before it has been created? Or is there possibly a naming miscommunication between the directory and the project properties? I have created blank project and transferred code/vb form over and run into the same error. This leads me to believe that there is some error in my code?

This is the first section of my code, everything after this is categorized into regions under Class Form1.

Imports System.Windows.Forms
Imports System.Windows.Controls.Label
Imports System.IO
Imports System
Imports System.Text.RegularExpressions
Imports Microsoft.Office.Interop
Imports LMSTestLabAutomation
Imports System.IO.File
Imports System.IO.Path
Imports System.Threading
Imports System.ComponentModel
Imports System.Runtime.InteropServices

Class Form1
    Dim TL As LMSTestLabAutomation.Application
    Public tlDb As IDatabase
    Dim SaveDataName As String
    'Declare UA variables
    Dim UAmodel, UAtype, UAsn, UAoperator, UAdate, UAcomment,
        UAtesttype, UAtestpurpose, UAtime, UAtestduration As String
    Dim UAlist As New SortedList(Of String, String)
    Dim AcqState As String = "Acquisition Offline"
    Dim aRecordTime As Boolean() = New Boolean() {}
    Dim aRunNames As String() = New String() {}
    Dim aProjectNames As String() = New String() {}
    Dim aStatus As String() = New String() {}
    Dim aStartTrigger As Single() = New Single() {}
    Dim aStopTrigger As Single() = New Single() {}
    Dim aTriggerCondition As String() = New String() {}
    Dim aSequences As Integer() = New Integer() {}
    Dim newTestIncrement As Integer
    Dim newTest As String() = aRunNames
    'Declarations of the used objects
    Dim database As LMSTestLabAutomation.IDatabase
    Dim datawatch_pictManag As LMSTestLabAutomation.IDataWatch
    Dim WithEvents gDataWatch_AcqState As LMSTestLabAutomation.DataWatch
    Dim pictManag As LMSTestLabAutomation.IPictureManager
    Dim myPicture As LMSTestLabAutomation.IPicture
    Dim myBlock As LMSTestLabAutomation.IBlock2
    Dim myDisplay As LMSTestLabAutomation.IDisplay
    Dim Measure_Port As LMSTestLabAutomation.DataWatch
    Dim Open_book = TL.ActiveBook
    Dim sequence_number = Open_book(0, 2)

runtime exception

vb.net
visual-studio
asked on Stack Overflow Oct 22, 2019 by Luke • edited Oct 23, 2019 by Luke

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0