Search code examples
c#asp.netnamespacesapp-code

How come classes in subfolders in my App_Code folder are not being found correctly?


I am getting the following error when I put class files in subfolders of my App_Code folder:

errorCS0246: The type or namespace name 'MyClassName' could not be found (are you missing a using directive or an assembly reference?)

This class is not in a namespace at all. Any ideas?


Solution

  • You need to add codeSubDirectories to your compilation element in web.config

    <configuration>
        <system.web>
          <compilation>
             <codeSubDirectories>
               <add directoryName="View"/>
             </codeSubDirectories>
          </compilation>
       </system.web>
    </configuration>