I just spent the last 20 minutes bashing my head against this problem, and I know that at some point it's going to come back and bite me again and I'm not going to remember how I fixed it, so this blog post is really just a reminder to my future self that this is how I fixed it - hopefully it will help others too.
I just added files from our source code repository that were contained within a folder within my APP_CODE directory. No sooner as I added them and I started getting the following error at every line that referenced objects contained in other files that resided directly in my APP_CODE directory.
"The type or namespace name could not be found are you missing a using directive"
I immediately checked that the namespaces were referenced correctly - and they were. I checked that the classes I were referencing were marked as public and that I could access them directly, and indeed, they were and I should.
My colleague @JohnMacIntyre (in a rare moment of brilliance) told me to check the web.config for the compilation settings. Sure enough I found:
<compilation debug="true"> <codeSubDirectories> <add directoryName="helpers"/> </codeSubDirectories> <assemblies> <add assembly="System.Transactions, Version=184.108.40.206, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Core, Version=220.127.116.11, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.Extensions, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Xml.Linq, Version=22.214.171.124, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.DataSetExtensions, Version=126.96.36.199, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation>
I removed the <codeSubDirectories> section and hey presto, suddenly everything works again. The order of compilation is top-down with the APP_CODE directory being compiled last consequently if you have multiple folders defined here, code in earlier folders cannot be 'seen' by code in subsequent folders but not the other way around and none of the code in these folders can see code in your APP_CODE folder, however code in your APP_CODE folder can see all the code in those folders.