Intermittent compiler error

G

Guest

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
 
C

Charles Law

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 said:
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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top