【问题标题】:Strange runtime issue VB.net奇怪的运行时问题 VB.net
【发布时间】:2012-11-23 00:24:48
【问题描述】:

我正在完成的 VB.net 程序存在以下问题。基本上我有两种形式。 Form1techs。表格 1 首先加载,是我的“主”页面。我想在 Form1 上引用技术中的变量。我公开声明了这个变量:

 Public jobID As String

然后我在 Form1 上这样引用它:

Dim job As String = techs.jobID

这是我得到的错误:

An error occurred creating the form. See Exception.InnerException for details.  The error is: An error occurred creating the form. See Exception.InnerException for details.  The error is: The form referred to itself during construction from a default instance, which led to infinite recursion.  Within the Form's constructor refer to the form using 'Me.'

谁能告诉我这里出了什么问题?

【问题讨论】:

  • 你能展示一下techs的构造函数吗?即创建第二种形式的实例的代码。
  • 事实上,考虑到这一点,我认为问题在于技术人员将其引用为在被引用之前尚未构造的变量。
  • 必须先实例化技术
  • 请将内部异常中的文本添加到您的问题中,因为我无法重现您的问题!

标签: vb.net winforms


【解决方案1】:

尝试改变

Public jobID As String

Public Shared jobID As String

【讨论】:

    【解决方案2】:

    实例化第一技术

    Dim newtechs As New techs()
    

    然后,将 techs.jobID 赋给 Form1 下的字符串变量

    Dim job As String = newtechs.jobID
    

    【讨论】:

    • Dim job As String = newtechs.jobID
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 2012-01-13
    • 1970-01-01
    相关资源
    最近更新 更多