views:

2498

answers:

3

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?

A: 

Is it possible that you haven't set the folder as an application in IIS (or your web server)? If not, then the App_Code that gets used is that from the parent folder (or the next application upwards).

Ensure that the folder is marked as an application, and uses the correct version of ASP.NET.

Marc Gravell
Classes in my App_Code folder directly work, if I put App_Code/View or something I get the error for classes in the View Sub-Directory
Greg
A: 

As you add folders to your app_code, they are getting separated by different namespaces, if I recall correctly, using the default namespace as the root, then adding for each folder.

Mitchel Sellers
+5  A: 

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>
AnthonyWJones