I recently converted a solution from VS2005 to VS2010. After changing all of my projects to target .NET Framework 4.0, I was plagued with the dreaded CS0246:
The type or namespace name ‘type/namespace’ could not be found (are you missing a using directive or an assembly reference?)
As suggested in the numerous blog posts I found…
- I verified that all of my projects were targeting the same Framework version (4.0 vs. 4.0 Client Profile).
- I relaunched Visual Studio (several times).
- I cleaned and rebuilt (several times).
- I removed and re-added references.
- I disabled my one and only add-on (Resharper).
After all of that, it still wouldn’t build.
It turns out that the error was in my config files. Several months ago, we used assembly redirection to resolve some version conflicts:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31BF3856AD364E35" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0"/> </dependentAssembly> </assemblyBinding> </runtime>
As soon as I removed the redirection, all of my projects built successfully.