Error BC30002 - Type XXX is not defined

Okay, this is starting to drive me crazy. I have an asp.net webapp. Pretty simple, most of the code in .aspx.vb and a few classes in App_Code.

The problem that started to occur only today (although most of the code has already been written) is that from time to time I have this error message:

Error BC30002: Type 'XXX not defined

An error occurs every time I modify files in the App_Code folder. EDIT: Well, this happens if I don't touch anything and then refresh the page. I'm still trying to figure out how to cause this error.

I just need to wait a bit without touching anything and then refresh the page and it works, but it is very annoying.

So, I searched a little, but nothing happened except import. Any idea?

+5
source share
4 answers

I think I found the problem.

My code was like this:

Imports CMS

Sub Whatever()
    Dim a as new Arbo.MyObject() ' Arbo is a namespace inside CMS
    Dim b as new Util.MyOtherObject() ' Util is a namespace inside Util
End Sub

I'm not sure why I wrote it this way, but it turns out the fact that I called classes without calling their entire namespace or importing their entire namespace caused an error.

I rewrote it as follows:

Imports CMS.Arbo
Imports CMS.Util 

Sub Whatever()
    Dim a as new MyObject()
    Dim b as new MyOtherObject()
End Sub

And now it works ...

+4
source

Sounds like a compilation problem, especially because you mention that you get an error, and then wait and it disappears. ASP.NET may still be in the process of dynamically compiling your application, or it will compile types into different assemblies.

, codebehind, . , , , .

@Reference, , , , .

@ - MSDN

+4

, , ( , app_code, , , IIS, - X ).

, , asp.net . .

19.3 , . !

0

, . Target, "" , .

0

All Articles