views:

186

answers:

3

I have created a website in ASP.net and have created a class and put it inside of the App_Code folder. However I cannot access this from my other pages. Does something need to be configured to allow this? It's worked in a previous project - but not this one.

namespace CLIck10.App_Code
{
    public static class Glob
    {
        ...
    }
}
+6  A: 

Right click on the .cs file in the App_Code folder and check its properties. Make sure the Build Action is set to Compile

FailBoy
How can you set this as the default build action? or do I have to do that for every file in the App_Code folder?
Malachi
@Malachi - it should be the default action on that folder. How are you adding classes to it?
Zhaph - Ben Duguid
This saved me today.
byte
+1  A: 

Put this at the top of the other files where you want to access the class:

using CLIck10.App_Code;

OR access the class from other files like this:

CLIck10.App_Code.Glob

Not sure if that's your issue or not but if you were new to C# then this is an easy one to get tripped up on.

AaronLS
It was something to do with the build action by the look of it - FailBoy's answer solved the problem. Thanks for replying anyway :)
Malachi
A: 

make sure that you are using the same namespace as your pages