App_Code namespace error

Last post 10-06-2009 7:29 AM by nripinbabu@msn.com. 13 replies.

Sort Posts:

  • App_Code namespace error

    11-13-2007, 4:39 PM
    • Member
      24 point Member
    • roxie
    • Member since 05-22-2007, 3:10 AM
    • Posts 41

    Hi, I have a c# app that I've been working on and I added a new class to the App_Code directory.

    I wanted to use the class in one of my aspx pages, so I tried to add a using statement in my code behind

    that referenced the class. I tried EVERYTHING and I consistently got compile errors stating
     

    The type or namespace name does not exist in the namespace  (are you missing an assembly reference?)         

     Eventually, I just created a new directory called 'classes' and copied the class over from

    App_Code, and then it worked COMPLETELY FINE. It just wouldn't compile when the class was stored

    in App_Code. God that was frustrating. I thought that's what App_Code was for. What gives?
     

     

  • Re: App_Code namespace error

    11-13-2007, 5:36 PM

    I use the App_Code folder for a generic class that all my page-related classes inherit from, as well as helper classes.  Instead of Using the class, the child classes inherit, so maybe there's a difference there.  I'm pretty sure that Using is just for dlls.

    There seems to be confusion in the development community about exactly what the App_Code directory is for. 

    I love to display the non-secure items...
    Charlie Asbornsen
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: App_Code namespace error

    11-14-2007, 10:23 AM
    • Member
      24 point Member
    • roxie
    • Member since 05-22-2007, 3:10 AM
    • Posts 41

    Well from what I understand, the App_code directory is for code that you want compiled at runtime. However, it just doesn't seem to work. The namespaces don't work, code outside of App_code can't see the code in App_Code.

     It's very frustrating.
     

  • Re: App_Code namespace error

    11-14-2007, 11:10 AM

    I don't know what to say.  I have a class called Helper.cs in App_Code and I can call methods in it from a generic class in the app with no problem.  The helper's namespace is MyWeb.App_Code. 

    I love to display the non-secure items...
    Charlie Asbornsen
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: App_Code namespace error

    11-14-2007, 12:43 PM
    • Member
      24 point Member
    • roxie
    • Member since 05-22-2007, 3:10 AM
    • Posts 41

    Do you have a using statement? (in the consuming class).

    Or do you just call methods in helper.cs as you would if they were members of the same class? 

  • Re: App_Code namespace error

    11-14-2007, 1:39 PM

    The Using statement is Using MyApp.App_Code

    Then I can call Helper.Method()

     

    I love to display the non-secure items...
    Charlie Asbornsen
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: App_Code namespace error

    11-15-2007, 1:38 PM
    Answer
    • Member
      14 point Member
    • bpeterson
    • Member since 11-15-2007, 6:33 PM
    • NC
    • Posts 2

     I don't know if your having the same problem but in my projects when I add a new .cs file to the app_code folder it marks it as "content" instead of "compile".  I have to change it manually to get the application to compile without errors.

  • Re: App_Code namespace error

    11-15-2007, 3:47 PM
    • Member
      24 point Member
    • roxie
    • Member since 05-22-2007, 3:10 AM
    • Posts 41

    Hey... that was it!

    when I changed the setting for the class file to compile instead of content it worked.

    Now what I need to figure out is if it's set to compile, will it compile at runtime or just when I do a build. Time will tell on that one after I test. 

  • Re: App_Code namespace error

    11-15-2007, 4:01 PM

    bpeterson - Where are you in NC?

    I love to display the non-secure items...
    Charlie Asbornsen
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: App_Code namespace error

    11-15-2007, 4:09 PM
    • Member
      14 point Member
    • bpeterson
    • Member since 11-15-2007, 6:33 PM
    • NC
    • Posts 2

    I work in Raleigh for the DOT..   

     

    .......No traffic jokes ok Wink

  • Re: App_Code namespace error

    11-15-2007, 4:48 PM

    bp - sent you a private message.

    I love to display the non-secure items...
    Charlie Asbornsen
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: App_Code namespace error

    12-04-2007, 8:06 PM
    • Member
      2 point Member
    • Husainie
    • Member since 08-26-2003, 6:20 AM
    • Shah Alam, Malaysia
    • Posts 1

    Use this on your  *.aspx file

    <%@ Page Language="VB"  Src="your_class_file.vb"  .........

     

     

    Husainie.Canon.Malaysia
  • Re: App_Code namespace error

    03-12-2009, 8:15 PM
    • Member
      5 point Member
    • Mike1298
    • Member since 03-12-2009, 11:57 PM
    • Posts 2

    This was my problem too. Thank you for your help. I had asked many forums and people but nobody could answer it. Then, I had to find out how to mark a file “compile” or “content”. This is how I did it. In VS 2005, to mark a file in App_Code directory “content” or “compile”, click on the filename then in the properties window (usually located below the solution explorer window), find “Build Action” property which itself is grouped under “Advanced”. Then select Content or Compile.

     

    Mike

  • Re: App_Code namespace error

    10-06-2009, 7:29 AM

    bpeterson:

     I don't know if your having the same problem but in my projects when I add a new .cs file to the app_code folder it marks it as "content" instead of "compile".  I have to change it manually to get the application to compile without errors.


    Way to Go mate !!!!

    Love your tip there Cool


    Cheers!!!!

Page 1 of 1 (14 items)