虚假的“未定义”错误消息 [英] Spurious "Not Defined" error messages

查看:70
本文介绍了虚假的“未定义”错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个项目,其中引用了许多其他项目(所有这些项目都在项目级别引用并包含在解决方案中)。频繁地,如果我们在项目A中进行改变(例如添加属性,或者甚至简单地改变代码行),则项目B中的表单将显示10个或更多个对象,诸如此类的未定义。 。为了解决这个问题,我们检查项目B中的表单,并在90%的时间内修复它(但代码或表单上没有任何变化 - 如果我们检查代码,我们的存储库只是忽略它,因为代码没有'没改变!)。另外10%的时间,我们解决了问题,但是从Windows窗体设计器生成的代码中删除了一行。声明所有对象的部分(Friend Withevents ...)并简单地将其粘贴回来 - 再次,没有变化


我正在使用VS.NET 2003


这已经很烦人了一段时间,但现在它失控了,经常以3种或更多形式显示一百条错误消息,所有这些都必须检查出来在应用程序编译之前签出。这真的破坏了思路,你可以想象


任何建议都会非常感激!

解决方案

< blockquote>我在以下情况下看到了这种行为:

- 项目A定义了一个带有Protected WithEvents变量的基类

- 项目B,在另一个程序集中,继承来自基类

项目A

- 项目B有一个事件处理程序方法,它处理来自项目A中定义的

WithEvents变量的事件


这个场景,尽管完全合法,但应该避免使用VB.NET

2003(和2002),因为IDE无法应对它(你''会得到你描述的

错误)。相反,使用AddHandler / RemoveHandler来处理

这样的事件。


AFAIK,MS应该知道这个问题,并希望修复它

已经为惠德贝了。


祝你好运,

Urs

Eric G. Harrison写道:

我们有一个项目,其中引用了许多其他项目(所有这些项目都在项目级别引用并包含在解决方案中)。频繁地,如果我们在项目A中进行改变(例如添加属性,或者甚至简单地改变代码行),则项目B中的表单将显示10个或更多个对象,诸如此类的未定义。 。为了解决这个问题,我们检查项目B中的表单,并在90%的时间内修复它(但代码或表单上没有任何变化 - 如果我们检查代码,我们的存储库只是忽略它,因为代码没有'没改变!)。另外10%的时间,我们解决了问题,但是从Windows窗体设计器生成的代码中删除了一行。声明所有对象的部分(Friend Withevents ...)并简单地将其粘贴回来 - 再次,没有变化。

我正在使用VS.NET 2003.

这已经很烦人了一段时间,但现在它失控了,经常以3种或更多形式显示一百条错误消息,所有这些都必须在应用程序之前检出并取消检出编译。正如你想象的那样,这真的破坏了思路!

任何建议都将不胜感激!




Urs,


感谢您在社区中发帖。


根据我的测试,我无法重现问题。

这是我的重现步骤。

[ProjectB]

Imports System.Windows.Forms

Public Class BaseClass
受保护的事件fm作为表格

私人str as String =" Test"

公共财产sk()As String

获取

返回str

结束获取

设置(ByVal值为字符串)

str = Value

结束套件

结束物业

结束班级


[ProjectA]

[Class1.vb]

公共类DerivedClass

继承ProjectA.BaseClass

公共子测试()

fm =新表格

fm.Show()

Me.sk =" Hello" < br $>
End Sub

Private Sub fm_Closing(ByVal sender As Object,ByVal e As

System.ComponentModel.CancelEventArgs)处理fm.Closing

MsgBox(" fm_Closing")

End Sub

Private Sub fm_Click(ByVal sender As Object,ByVal e As

System.EventArgs)处理fm.Click

MsgBox(" Click")

End Sub

End Class

[Form1.vb]

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Dim o As New ProjectB.DerivedClass

o.Test()

End Sub


我也是已经向ProjectA.BaseClass添加了一个新属性,然后按

Ctrl + Alt + B来构建解决方案,该事件将再次触发。


你能建立吗?复制样本尽可能简单,只要它能够重现问题,并通过删除在线发送给我。来自我的

电子邮件地址?

我期待着您的回复。


祝你好运,


Peter Huang

Microsoft在线合作伙伴支持


安全! - www.microsoft.com/security

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


嗨Eric,Urs,Peter。


我在工作在几个大型项目的大型解决方案中包含了

它。我也连接到Visual Source Safe。


只有两个开发人员在使用这个解决方案,我们俩都有同样的问题。我们甚至没有编辑过的项目中的错误..

通常在表格上...但有时在继承自Label的控件上..


错误在编译时出现,然后如果我查看违规表格

或类,然后注释掉定义它声称为
缺失的对象的行,然后取消注释相同的行,问题消失了几个

编译..然后重新出现..


当解决方案超过一个时,它似乎只是一个问题一定的尺寸..

我还有其他几个包含小项目的解决方案,问题

从来没有出现过..


所以我猜它与解决方案的大小有关..


这也意味着很难给出一个小的复制品关于

问题。


还有其他几个人遇到同样的问题..请参阅

microsoft.public中的帖子。 vsnet.ide于05Feb2004由Jeff Lindholm撰写,标题为编译

错误 - 仅有时候


我只能重复Urs所说的内容,并希望这个问题消失了

惠德贝!


这里希望,

Rigga。

" Eric G. Harrison" < ER *********** @ hotmail.com>在留言中写道

news:68 ********************************** @ microsof t.com ...

我们有一个项目,其中引用了许多其他项目(所有项目都是在项目级别引用的
,并包含在解决方案中)。

频繁地,如果我们在项目A中进行更改(例如添加属性,或者即使只是更改一行代码,也可以使用
),项目B中的表单将显示10
或更多未定义对象等。为了解决这个问题,我们检查了项目B中表格中的
以及修复它的90%的时间(但没有任何内容在代码或表单上发生变化
- 如果我们检查代码,我们的存储库

只是忽略它,因为代码没有改变!)。另外10%的时间,

我们解决了这个问题但是从Windows窗体设计器中删除了一行生成的代码声明所有对象的部分(朋友

Withevents ......)并简单地将其粘贴回来 - 再次,没有变化。
我正在使用VS.NET 2003。

这已经很烦人了一段时间,但现在已经失控了,
经常以3种或更多形式显示一百条错误消息,全部

在应用程序编译之前必须检查并取消检查。

这真的破坏了思路,正如你想象的那样!
任何建议都将不胜感激!



We have a project with many other projects referenced (all of which are referenced at the project level and are included in the solution). Frequenly, if we make a change in project A (such as adding a property, or even simply changing a line of code), a form in project B will then show 10 or more "object such-and-such is not defined". To fix this problem we check out the form in project B and 90% of the time that fixes it (but nothing changes in the code or on the form - if we check the code in, our repository just ignores it since the code hasn''t changed!). The other 10% of the time, we solve the problem but cutting a line out of the "Windows Form Designer Generated code" section where all the objects are declared (Friend Withevents...") and simply pasting it back in - again, no changes

I''m using VS.NET 2003

This has been pretty annoying for a while, but now it is out of control, frequently showing a hundred errors messages in 3 or more forms, all of which have to be checked out and un-checked out before the app will compile. This really derails the train of thought, as you can imagine

Any suggestions would be greatly appreciated!

解决方案

I saw this behaviour with the following situation:
- Project A defines a base class with a Protected WithEvents variable
- Project B, which is in another assembly, inherits from the base class
in project A
- Project B has an event handler method which handles events from the
WithEvents variable defined in project A

This scenario, altough completely legal, should be avoided with VB.NET
2003 (and 2002), since the IDE cannot cope with it (you''ll get the
errors you described). Instead, use AddHandler/RemoveHandler to handle
such events.

AFAIK, MS should be aware of this problem and has hopefully fixed it
already for Whidbey.

Best regards,
Urs
Eric G. Harrison wrote:

We have a project with many other projects referenced (all of which are referenced at the project level and are included in the solution). Frequenly, if we make a change in project A (such as adding a property, or even simply changing a line of code), a form in project B will then show 10 or more "object such-and-such is not defined". To fix this problem we check out the form in project B and 90% of the time that fixes it (but nothing changes in the code or on the form - if we check the code in, our repository just ignores it since the code hasn''t changed!). The other 10% of the time, we solve the problem but cutting a line out of the "Windows Form Designer Generated code" section where all the objects are declared (Friend Withevents...") and simply pasting it back in - again, no changes.

I''m using VS.NET 2003.

This has been pretty annoying for a while, but now it is out of control, frequently showing a hundred errors messages in 3 or more forms, all of which have to be checked out and un-checked out before the app will compile. This really derails the train of thought, as you can imagine!

Any suggestions would be greatly appreciated!




Hi Urs,

Thanks for posting in the community.

Based on my test, I can not reproduce the problem.
Here is my reproduce steps.
[ProjectB]
Imports System.Windows.Forms
Public Class BaseClass
Protected WithEvents fm As Form
Private str As String = "Test"
Public Property sk() As String
Get
Return str
End Get
Set(ByVal Value As String)
str = Value
End Set
End Property
End Class

[ProjectA]
[Class1.vb]
Public Class DerivedClass
Inherits ProjectA.BaseClass
Public Sub Test()
fm = New Form
fm.Show()
Me.sk = "Hello"
End Sub
Private Sub fm_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles fm.Closing
MsgBox("fm_Closing")
End Sub
Private Sub fm_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles fm.Click
MsgBox("Click")
End Sub
End Class

[Form1.vb]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim o As New ProjectB.DerivedClass
o.Test()
End Sub

Also I have added a new property to ProjectA.BaseClass and press
Ctrl+Alt+B to build the solution, the event will fire again.

Can you build a reproduce sample as simple as possible as long as it can
reproduce the problem, and send to me by removing the "online" from my
email address?
I look forward to hearing from you.

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.


Hi Eric, Urs, Peter.

I am working on a large solution with several large project included into
it. I also am connected to Visual Source Safe.

There are only two developers working on this solution, and both of us have
the same problem.. spurious errors in projects that we haven''t even edited..
usually on forms.. but sometimes on a control inherited from Label..

The errors appear upon compilation, then if I check out the offending Form
or Class then comment out the line defining the object it claims to be
missing, then uncomment the same line, the problem goes away for a few more
compiles.. then re-appears..

It only seems to be a problem when the solutions gets above a certain size..
I have several other solutions that contain small projects, and the problem
never occurs there..

So I would guess it has something to do with the size of the solution..

Also it means it is extremely difficult to give a small reproduction of the
problem.

also several others are having the same problem.. see post in
microsoft.public.vsnet.ide on 05Feb2004 by Jeff Lindholm, title "Compile
Errors - only sometimes"

I can only re-iterate what Urs stated, and hope this problem goes away with
Whidbey!

Here''s hoping,
Rigga.

"Eric G. Harrison" <er***********@hotmail.com> wrote in message
news:68**********************************@microsof t.com...

We have a project with many other projects referenced (all of which are referenced at the project level and are included in the solution).
Frequenly, if we make a change in project A (such as adding a property, or
even simply changing a line of code), a form in project B will then show 10
or more "object such-and-such is not defined". To fix this problem we check
out the form in project B and 90% of the time that fixes it (but nothing
changes in the code or on the form - if we check the code in, our repository
just ignores it since the code hasn''t changed!). The other 10% of the time,
we solve the problem but cutting a line out of the "Windows Form Designer
Generated code" section where all the objects are declared (Friend
Withevents...") and simply pasting it back in - again, no changes.
I''m using VS.NET 2003.

This has been pretty annoying for a while, but now it is out of control, frequently showing a hundred errors messages in 3 or more forms, all of
which have to be checked out and un-checked out before the app will compile.
This really derails the train of thought, as you can imagine!
Any suggestions would be greatly appreciated!



这篇关于虚假的“未定义”错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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