ASP.NET Compiler Error CS0006

Do you have arcane CS0006 errors haunting you, either in 1.1 or 2.0?  Something like this:

Compiler Error Message: CS0006: Metadata file 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\someProject\27bee1ac\cdebe31b\App_Code.glp37_b2.dll' could not be found

Source Error:

[No relevant source lines]

Additional symptoms: when you first build the app it works fine, but then when rebuilding it always comes up with this error.  Well, I know of three major reasons for this to occur:

  1. You've got a signed assembly (DLL) that you haven't installed in the GAC.
  2. You're using impersonation (via in web.config) and have not installed your DLL to the GAC.
  3. You have an assembly with a strong name properly installed in the GAC, but have now recompiled and thus have a new version.  You have then deleted the older one, leaving the CLR still looking for the older version based on its specific strong name.

For reasons #1 and #2, simply install your assembly in the GAC.

As a sidenote for reason #2, if it's impersonation you're after then you may want to check out Michele's excellent article promoting impersonation on demand:
http://www.theserverside.net/articles/showarticle.tss?id=SandboxingComponents

If you're facing reason #3 from the list, version trouble, then here's a good article on using publisher policy to get around the issue:

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconassemblyversionredirection.asp

And if that's confusing then you may want to start with this introductory article on versioning:
http://msdn.microsoft.com/library/en-us/dndotnet/html/managevers.asp


Feedback

# re: ASP.NET Compiler Error CS0006

I have the problem, but don't have 1, 2, or 3. Any other suggestions? 5/19/2006 12:49 PM | Travis

# re: ASP.NET Compiler Error CS0006

Hi

Here's a solution that works for us:

Look in Web.config - if you have the line <identity impersonate="true" /> then remove it.

Note that the problem does *not* occur if a username and password is specified in the <identity> setting.

Hope this helps

Andy
6/22/2006 12:39 AM | Andy Stephens

# re: ASP.NET Compiler Error CS0006

I found the solution to this problem that has been bugging me for a long time! I’ve searched and searched and seen a million articles address this problem, but the only solution anyone has is to use the GAC. I really didn’t want to use the GAC, and with this solution you don’t have to. I call it the "Terry Allen Solution." :-)

Yes, setting impersonate=false solves the problem. But what if you need to impersonate? Nearly all my applications do.

Solution:

Set impersonate = false for your whole web application:

<system.web>
<identity impersonate="false"/>

</system.web>


Put all your code under a directory and set impersonate to true for that location.


<location path="Web">
<system.web>
<identity impersonate = "true">
</system.web>
</location> 4/27/2007 1:30 PM | Terry Allen

# re: ASP.NET Compiler Error CS0006

Here's another solution; check the permissions for the relevant ASPNET (worker process) account on the %systemroot%\Temp and the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files directories.

Changing the permissions for the IIS_WPG group on the latter directory from Modify to Full corrected the issue without requiring a refresh of the worker processes in our case. 6/18/2007 1:10 PM | Andy

# re: ASP.NET Compiler Error CS0006

check this:

CS0006 if

1) 2 projects in 1 solution had the same assembly name
2) the path is too deep. Windows can hold maxpath 260 characters. If you have a webproject, the assembly is cached, check whether the cache location and the assembly name together do not exceed this limit. 2/22/2008 2:01 AM | Patrick Peters

Post a comment





 

Please add 1 and 3 and type the answer here:

News


Welcome to my blog.
Here's what we've got on the menu today:

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Syndication: