468,107 Members | 1,356 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

Intermittent compiler error

Using Visual Studio .NET 2003, I'm intermittently getting the VB.NET error BC30002 ("Type ... is not defined.") when I build a particular assembly that I have written. This error does not occur every time the assembly is built, and seems more likely to occur when a change has been made in the assembly and it is another dependent assembly that is being built.

The type that it claims is not defined is a nested class which is derived from another nested class within the parent class' base class. I.e., DerivedClass.DerivedNestedClass, defined as (in pseudo code):

public class DerivedClas
inherits BaseClas

protected class DerivedNestedClas
inherits BaseClass.NestedClas
Nov 22 '05 #1
2 1165
Hi Chris

This is one of those niggly things that is oft' reported but for which no
one seems to have a hard and fast resolution. I get exactly the same thing,
but hopefully the following will help:

I have found that the more tightly coupled a solution, the more likely the
problem is to occur. Also, check the references section of each project
properties in your solution, and make sure that there are no erroneous
entries. The order of the directories listed also seems to make a
difference. Try to be consistent in the order, i.e. order the references the
same way for each project.

The problem seems more prevalent when there are multiple classes with the
same name, or where a property has the same name as a class.

Organise classes to maintain the minimum scope across the solution, i.e.
make things private wherever possible, and refactor in order to decrease the
scope as far as possible.

HTH

Charles
"Chris Peacock" <ch****************@videss.co.uk> wrote in message
news:12**********************************@microsof t.com...
Using Visual Studio .NET 2003, I'm intermittently getting the VB.NET error BC30002 ("Type ... is not defined.") when I build a particular assembly that
I have written. This error does not occur every time the assembly is built,
and seems more likely to occur when a change has been made in the assembly
and it is another dependent assembly that is being built.
The type that it claims is not defined is a nested class which is derived from another nested class within the parent class' base class. I.e.,
DerivedClass.DerivedNestedClass, defined as (in pseudo code):-
public class DerivedClass
inherits BaseClass

protected class DerivedNestedClass
inherits BaseClass.NestedClass
.
.
.
end class
.
.
.
end class

public mustinherit class BaseClass
implements AnInterface

public mustinherit class NestedClass
.
.
.
end class
.
.
.
end class

AnInterface is used to expose a COM IDispatch interface to BaseClass (in case that's relevant).
When the compiler does not complain, all of the code seems to work fine. Almost always, changing something unrelated in the contents of the classes
involved makes the error go away - it will then appear again later, for no
apparent reason!
There is obviously a lot more to the class structure than I have shown here such as virtual (mustinherit) functions and properties. I've spent a
lot of time trying to tweak things to fix the problem, and so don't really
have time to pinpoint the exact cause of it - I was hoping someone else may
have experienced the same thing and be able to point me in the right
direction. I would happy to include more about the class structure on
request, however, if anyone has any ideas about this.
Thanks for any help.

Nov 22 '05 #2
Thanks Charles, I'll give these things a go. I wish MS would fix this problem though, as we've suffered with it since version 2002.
Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Chris Peacock | last post: by
8 posts views Thread by trinitypete | last post: by
3 posts views Thread by Lee Chapman | last post: by
reply views Thread by Shane C | last post: by
3 posts views Thread by =?Utf-8?B?UGF1bCBIYWxl?= | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.