Asked by:
Class File In App_Code Folder Not Recognized

Question
-
User1944709477 posted
Using VS 2008 / ASP.NET 3.5 / C#.
I notice that static methods defined in a class file (Util.cs) in App_Code are not recognized in the development environment until I open the class file once. (The methods Util.methodName in the file are underlined in Red with the tooltip 'The name Util does not exist in the current context').
The namespace in the class file is the same as the Page codebehind file in which it's methods are referenced, and the issue started happening suddenly.
Code compiles Ok, but it is an annoyance since the Intellisense does not work or it appears that the methods are not defined.
Any ideas on how to fix this is appreciated.
Wednesday, June 8, 2011 9:10 AM
All replies
-
User1315229986 posted
Is your application is a web site or web application?
If it is a web application then App_Code folder will not work in it insted place your class files in some other folder such as "CLASSES"
Wednesday, June 8, 2011 10:03 AM -
User1944709477 posted
How can I tell if it is a web site or web application? The buid options indicate 'Build Web Site' so I assume that it is a web site app.
Wednesday, June 8, 2011 10:32 AM -
User1315229986 posted
Could you please post the code of Util.cs class and how you are accessing it
Thursday, June 9, 2011 2:33 AM -
User1944709477 posted
The class file is too big to post. Its static functions are accessed by fully qualified names, such as Util.MethodName().
Thursday, June 9, 2011 12:20 PM -
User604186779 posted
I notice that static methods defined in a class file (Util.cs) in App_Code are not recognized in the development environment until I open the class file once. (The methods Util.methodName in the file are underlined in Red with the tooltip 'The name Util does not exist in the current context').If the Util.cs file has static class you can access the method using
Util.methodname();
if not create an instance to access the method.
Thursday, June 9, 2011 12:44 PM -
User1944709477 posted
Thank you for the response.
Please read my question carefully and understand the issue - I know how to access methods. You are stating the obvious, which is not of any help.
Thursday, June 9, 2011 12:58 PM -
User604186779 posted
Give me the code with the sample method and how you accessing ?
then only we will came up the solution ..
Friday, June 10, 2011 12:46 PM -
User-650628323 posted
Hi,
To resolve your issue, the easy step to do it by selecting your class files in web application, then change the properties of the class content build to “compile”.
I would like to suggest you to check the link below for the detailed information about App_Code.
http://msdn.microsoft.com/en-us/library/t990ks23(v=vs.80).aspx
Best wishes,
Tuesday, June 14, 2011 3:15 AM -
User1944709477 posted
Class files in the App_Code folder do not have properties.
Saturday, June 25, 2011 4:12 PM -
User-821857111 posted
Class files in the App_Code folder do not have properties.Select one in your Solution Explorer window by clicking it once. Then press F4. You should get a properties window appear for the selected file. the first oprtion in the Advanced properties section is Build Action. That should be set to compile.
Saturday, June 25, 2011 4:40 PM -
User1944709477 posted
Thank you.
The properties window only shows two attributes:File Name and Full Path.
I also tried with other .cs files, the properties display the same two properties only.
Saturday, June 25, 2011 4:53 PM