Today I came across this error while working on an ASP.Net web project:
The given assembly name or codebase, '[ASSEMBLY NAME]', was invalid
Source File: c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config
The error also contained the log of probing steps that .Net was using to find the dependency. For time's sake I won't paste all of it in
I messed around forever re-referencing external dependencies and re-building the .Net solution trying to get this to work, but had no luck. Then a colleague asked when the problem started happening and what changed between when the project WAS working and when it stopped working. So then the gears started turning...
Yesterday I needed to move the ASP.Net web project to a different physical working directory on my machine. It was residing under c:\inetpub\wwwroot\[project] but needed to be moved to where the solution was being stored (under c:\development\[solution]\[project]). After the move was finished, that's when we started seeing this error.
The move resulted in a very long-named file path to the solution and project files. The projects/assemblies themselves also have long names. e.g. c:\development\MyWonderfulCompany.MyGreatProject\MyWonderfulCompany.MyGreatProject.CompanyMarketingData.DomainObjects.
After googling a little bit, I came across this article: http://khsw.blogspot.com/2005/08/given-assembly-name-or-codebase-was.html. It suggests that there is a maximum number of characters that can be used for the full path to an assembly when the assembly is cached in ASP.Net's temporary internet files folder. I located the dependency that was named in the error, and it was found in this temporary internet files location:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\development_CLIENTNAME.PROJECT_CLIENTNAME.APPNAME.web\
abd06194\52f4d6a7\assembly\dl2\0b533913\ab564c8a_25e6c501\CLIENTNAME.DEPENDENCYNAME.dll
That's a long path.
So to test this theory, I created a new ASP.Net web project in the solution with a shorter name (e.g. just [Project] rather than [Client].[Project].Web) just to shorten things up a bit. I added all of the same dependencies from the original, broken project. To my slight suprise, it worked perfectly. I then added another ASP.Net web project to the solution and gave it a name with the same number of characters as the broken web project. I then added the same dependencies again, ran it, and it broke with the same error.
There might be some other work arounds besides using a shorter project name, but I haven't tried anything else yet.
So, be careful with the length of your VS.Net project names if you're doing ASP.Net web development.