473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Spurious "Not Defined" error messages

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!
Nov 20 '05 #1
10 1617
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!


Nov 20 '05 #2
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.

Nov 20 '05 #3
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!

Nov 20 '05 #4
Peter,
as said, this the error will only show up very spuriously (sometimes not
for weeks, and then all of a sudden multiple times a day!), and it seems
like it only shows up on large projects, not on small ones. That means,
sorry, I cannot give you a simple expample.

We had this problem about half a year ago and cleaned up all the
Protected Withevents variables then. I'm sorry I cannot rebuild the
project with the state half a year ago.

It seems to have to do with Building a project (not *re*building) it,
since when you rebuild it the problem goes away.

Sorry I can't be of more help
Urs
Peter Huang wrote:
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.


Nov 20 '05 #5
Rigga,
did you check if you have this Protected WithEvents scenario I
described? Since we got rid of those constructs and consequently avoid
them, we never had this problem again.
Urs

Rigga wrote:
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!



Nov 20 '05 #6
Peter, obviously othesr are running into this problem and have posted more information. Thanks for your quick reply!
Nov 20 '05 #7
Urs, we're not using exactly that construct, but we are using some components from Infragistics that are using Friend WithEvents in their declarations. Other than that, it sounds like the same problem. Later tonight we're going to take the form that we're inheriting from and move it into the same project as the derived classes

Thanks again, and I'm glad to see all the other responses - this is obviously a real problem!
Nov 20 '05 #8
Hi,

Thanks for posting in the community.

I am researching the issue, if I have new information, I will update with
you ASAP.
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.

Nov 20 '05 #9
Hi,

I still can not reproduce the problem I also try to add my solution to the
Visual source safe.

To isolate the problem, I think you may try to re create a new solution and
add the projects and rebuild the project one by one to the solution to see
if the problem persists.

Also you may try to copy the whole solution to another machine to see if
the problem persists.

You may also take a look at the build log in the OutPut panel, to see if
all of the projects build successful.

Please try my suggestion and let me know the result.

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.

Nov 20 '05 #10
Urs,

I don't think we have this Protected WithEvents situation exactly as you
describe it...
but we do use Protected WithEvents to define some object.. but usually
handle any events in the same class / form where they are defined..

Rigga.

"Urs Eichmann" <no****@nospam.ch> wrote in message
news:uu**************@TK2MSFTNGP11.phx.gbl...
Rigga,
did you check if you have this Protected WithEvents scenario I
described? Since we got rid of those constructs and consequently avoid
them, we never had this problem again.
Urs

Rigga wrote:
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!


Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dmitry | last post by:
Hello, Sometimes on js code execution Mozilla 1.5 prints in JS concole the following error: "Error: fn is not defined" where "fn" is the function name surely defined _before_ the line that...
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
11
by: MLH | last post by:
I copied the following code snippet from A97 HELP. Am getting an error at compile time suggesting there's a problem with the first line (compile error, user-defined type not defined). It is likely...
6
by: david | last post by:
When I compile a window form client for web service, there is error message as follows: Program 'D:\usr\winVBcontrol\WinClient4WebServiceFileCS\obj\Debug\WinClient4WebServiceFileCS.exe' does not...
2
by: Yannick Turgeon | last post by:
Hello, I'm using A97 (french version) on XP (english version). Since this afternoon, all the Access built-in french-equivalent function are generating a "Sub or Function not defined" error. An...
3
by: KelHemp | last post by:
I have compiled data from 13 tables, one for each month of the year that hold 45 fields each, and another for employee information, that holds 16 fields. The database is intended to record hours and...
2
by: =?Utf-8?B?UmFscGggSQ==?= | last post by:
OK, Dell inspirion 9300 - 100 gb hd partitioned into 3 drives C: OS 10 gb D: Programs 20 gb E: Data 70 GB Page Files 0 on C: 4092 on D: 3070 on E:
6
by: newholborn | last post by:
Hi everyone. I have some questions, which should be rather easy to reply, but as I am working on PHP, JavaScript, XML, CSS, Photoshop and other stuff at the same time, my head, which is about to...
2
by: jmike | last post by:
I'm using some legacy code that has a user-defined exception in it. The top level program includes this line from TestRunError import * It also imports several other modules. These other...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.