Error BC30002 - Type XXX is not defined

前端 未结 5 1423
春和景丽
春和景丽 2021-01-17 11:54

OK, this begins to drive me crazy. I have an asp.net webapp. Pretty straightforward, most of the code in the .aspx.vb, and a few classes in App_Code.

The problem, wh

相关标签:
5条回答
  • 2021-01-17 12:05

    Replace your vbproj and vbproj.user file from your backup before if the references are equal

    0 讨论(0)
  • 2021-01-17 12:14

    Sounds like it happens every time the website spins up (the app gets recycled every time you touch app_code and probably you have IIS configured to shut down the website after X minutes of inactivity).

    I bet it has something to do with the asp.net worker process not having the correct access rights on the server. So its trying to load an assembly and is being denied.

    Check this link and Table 19.3 for a list of all the folders the worker process account must have access to in order to function. And don't forget to give it rights to all files and folders in your virtual directory!

    0 讨论(0)
  • 2021-01-17 12:19

    This happened to me after I added a new project to an old solution. I lowered the Target framework to match that of the other 'older' projects and the error went away.

    0 讨论(0)
  • 2021-01-17 12:31

    I think I found the problem.

    My code was like that :

    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 like that, but it turns out the fact I was calling classes without either calling their whole namespace or importing their whole namespace was triggering the error.

    I rewrote it like this :

    Imports CMS.Arbo
    Imports CMS.Util 
    
    Sub Whatever()
        Dim a as new MyObject()
        Dim b as new MyOtherObject()
    End Sub
    

    And now it works...

    0 讨论(0)
  • 2021-01-17 12:32

    Sounds like a pre compile issue, particularly because you mention that you get the error and then wait and it disappears. ASP.NET may be still in the process of dynamically compiling your application or it has compiled the types into different assemblies.

    With dynamic compilation, you are not guaranteed to have different codebehind files compiled into the same assembly. So the type you are referencing may not be able to be resolved within its precompiled assembly.

    Try using the "@Reference" directive to indicate to the runtime that your page and the file that contains your type should be compiled into the same assembly.

    @ Reference - MSDN

    0 讨论(0)
提交回复
热议问题