vb.net - System.InvalidOperationException: '创建表单时出错
问题描述
在尝试运行/调试 WindowsForm 的代码时,我遇到了以下异常:
System.InvalidOperationException HResult=0x80131509 消息=创建表单时出错。有关详细信息,请参阅 Exception.InnerException。错误是:对象引用未设置为对象的实例。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()在 C:\Users\M0110823\source\repos\Automated SoundPower Testing\My Project\Application.Designer.vb:第 35 行 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() 在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel( ) 在 Microsoft.VisualBasic。
内部异常 1:NullReferenceException:对象引用未设置为对象的实例。”
此异常参考:
Me.MainForm = Global.Automated_SoundPower_Testing.Form1
我认为这可能是因为我试图在创建之前调用 Me.Mainform ?还是目录和项目属性之间可能存在命名错误?我创建了空白项目并传输了代码/vb 表单并遇到了同样的错误。这让我相信我的代码中有一些错误?
这是我的代码的第一部分,之后的所有内容都被分类到 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)
解决方案
推荐阅读
- asp.net - Couldn't install Microsoft.VisualStudio.AspNet45.Feature
- javascript - 生成 HTML 到 PDF,并使用 Laravel 将生成的 PDF 上传到数据库?
- export - Kivy:任意比例的 export_to_png()
- scala - 如何使用 FS2 中的分类器功能对对象进行分组?
- php - PHP - 获取ajax获取的变量
- php - 如何使用正则表达式仅获取操作数
- ruby-on-rails - 无法将 rails 应用程序推送到 Heroku turbolinks
- java - 如何将某个字符串放入 *if* 并检查它是否是某个单词
- javascript - 如何组合两个返回 Rx Observables 的相似 http 请求?
- node.js - 如何允许电报机器人检查命令的可选参数