从另一个表单打开表单时出错 [英] Error Opening Form from another Form

查看:94
本文介绍了从另一个表单打开表单时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能理解在VB.Net中使用表单的问题,

与VB不同。我有一个表单在后台运行,任务栏中有一个图标

。右键单击图标会显示一个选项列表,其中一个是
,用于显示关于表单。在此表单显示后,我收到错误

说对象引用未设置为对象的实例。我已经尝试了

打开表格


frmAbout.Show

frmAbout.ShowDialog




昏暗的frmAbout2作为新的frmAbout


frmAbout2.ShowDialog()


frmAbout2.Show


但我仍然得到同样的错误。我如何解决这个问题?


谢谢,


Norm

解决方案
"范数" <否**** @ newsgroups.nospam> schrieb:

我不能理解在VB.Net中使用与VB不同的表格。我有一个表单在后台运行,任务栏中有一个
图标
。右键单击该图标会为您提供一个选项列表,其中一个选项显示一个关于表单。在此表单显示后,我收到错误
说对象引用未设置为对象的实例。我已经尝试用


打开表单。错误究竟发生在哪里? IDE是否指向某一行?

您在表单上使用了哪些控件?


Dim frmAbout2作为新的frmAbout
[。 ..]
frmAbout2.Show




这基本上应该有效...


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http: //classicvb.org/petition/>


完整的错误是

类型''系统的未处理异常。 NullReferenceException''发生在

system.windows.forms.dll


附加信息:对象引用未设置为
$ b的实例$ b对象。


IDE在表格

显示之后突出显示调用第二个表格的原始行。


我尝试了几种不同的形式作为frmAbout并得到相同的

错误。


Norm

" Herfried K瓦格纳[MVP]&q UOT; <喜*************** @ gmx.at>在留言中写道

新闻:%2 ****************** @ TK2MSFTNGP14.phx.gbl ...

"范数" <否**** @ newsgroups.nospam> schrieb:

我不能理解在VB.Net
中使用与VB不同的表格。我有一个表单在后台运行,任务栏中有一个
图标
。右键单击该图标会为您提供一个选项列表,其中一个选项显示一个关于表单。在此表单显示后,我收到错误
说对象引用未设置为对象的实例。我已经尝试用

打开表单

错误发生在哪里? IDE是否指向某一行?
您在表单上使用了哪些控件?

并且
Dim frmAbout2作为新的frmAbout
[。 ..]
frmAbout2.Show



这基本上应该有效...

- MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>



您好


感谢您提供的信息。

要解决问题,您可以帮助构建最简单的重现吗? />
样本并在新闻组中发帖,如果您有任何疑虑,您也可以通过删除在线发送给我的
来自我的电子邮件地址。


基本上,以另一种形式显示一个表单不会导致异常,我认为我们需要更多信息来解决问题,谢谢你提前付出的努力。


祝你好运,


Peter Huang

Microsoft在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有授予任何权利。


I must not be understanding something about the use of forms in VB.Net that
is different from VB. I have one form running in the background with an icon
in the task bar. Right clicking on the icon gives you a list of options, one
of which is to show an About form. After this form shows I get an error
saying "Object reference not set to an instance of the object." I have tried
opening the form with

frmAbout.Show
frmAbout.ShowDialog

And
Dim frmAbout2 As New frmAbout

frmAbout2.ShowDialog()

frmAbout2.Show

But I still get the same error. How do I fix this problem?

Thanks,

Norm

解决方案

"Norm" <No****@newsgroups.nospam> schrieb:

I must not be understanding something about the use of forms in VB.Net that
is different from VB. I have one form running in the background with an
icon
in the task bar. Right clicking on the icon gives you a list of options,
one
of which is to show an About form. After this form shows I get an error
saying "Object reference not set to an instance of the object." I have
tried
opening the form with
Where exactly does the error occur? Does the IDE point to a certain line?
Which controls are you using on the form?
And
Dim frmAbout2 As New frmAbout
[...]
frmAbout2.Show



This should basically work...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


The complete error is
An unhandled exception of type ''System.NullReferenceException'' occurred in
system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object.

The IDE highlights the original line calling the second form after the form
shows.

I have tried this with several different forms as frmAbout and get the same
error.

Norm
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...

"Norm" <No****@newsgroups.nospam> schrieb:

I must not be understanding something about the use of forms in VB.Net that is different from VB. I have one form running in the background with an
icon
in the task bar. Right clicking on the icon gives you a list of options,
one
of which is to show an About form. After this form shows I get an error
saying "Object reference not set to an instance of the object." I have
tried
opening the form with



Where exactly does the error occur? Does the IDE point to a certain line?
Which controls are you using on the form?

And
Dim frmAbout2 As New frmAbout
[...]
frmAbout2.Show



This should basically work...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



Hi

Thanks for your information.
To troubleshooting the problem, can you help to build a simplest reproduce
sample and post in the newsgroup, if you have any concern, you may also
send to me via removing the "online" from the my email address.

Basically, show one form in another form will not cause the exception, I
think we need more information to troubleshooting the problem, thanks for
your efforts in advance.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


这篇关于从另一个表单打开表单时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆