Alex Rivera | Logout

Error BC30002 - Type XXX is not defined

Asked 2008-09-17T16:33:58.440
15

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, which has begun to occur only today (even though most of the code was already written), is that once in a while, I have this error message :

Error BC30002: Type ‘XXX’ is not defined

The error occurs about every time I modify the files in the App_Code folder. EDIT : OK, this happens also if I don't touch anything for a while then refresh the page. I'm still trying to figure out exactly how to trigger this error.

I just have to wait a little bit without touching anything, then refresh the page and it works, but it's very annoying.

So I searched a little bit, but nothing came up except imports missing. Any idea ?

Edit
Report

2 Answers

5

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

answered 2008-09-17T16:57:41.237
0

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!

answered 2008-09-17T17:07:46.470

Your Answer