본문 바로가기

.NET/ASP.NET

App_Code Subfolder Configuration Problem app_Code 안에서 서브 폴더 접근

반응형

App_Code Subfolder Configuration Problem

Last post 12-24-2008 2:28 AM by Thomas Sun – MSFT. 1 replies.

Sort Posts: 

  • App_Code Subfolder Configuration Problem

    12-20-2008, 7:55 PM
    • Member
      349 point Member
    • etbramble
    • Joined on 11-26-2006, 6:53 PM
    • Maryland
    • Posts 81
    • Points 349

    Hello...

     I am using subfolders in my App_Code folder.  I have code files (.cs) in both the App_Code root and the subfolders.  My problem is that I would like to access objects in a code file in the App_Code root in one of the subfolder classes, but can not access the objects in the root code files. 

    To illustrate the problem I want to access an use an object that has been coded in Codefile5.cs in a class in Codefile1.cs.  In another post I saw that putting the objects/classes in Namespaces will solve the issue, but when I tried I did not have any luck.  How can I make this work?

    ·         App_Code

    o   Subfolder1

    §  Codefile1.cs

    §  Codefile2.cs

    o   Subfolder2

    §  Codefile3.cs

    §  Codefile4.cs

    o   Codefile5.cs

    o   Codefile6.cs

     

     

    Filed under: 
  • Re: App_Code Subfolder Configuration Problem

    12-24-2008, 2:28 AM
    Answer

    Hi,

    Based on my understanding, I think you want to access class Codefile5 from class Codefile1, right?

    By default, the classes that are in the App_Code folder are available in whole website. So we need to make sure that this class is Public and the Namespace is correct if it has.

    Besides, did we set the compile order for these sub-directories of App_Code? If we setcodeSubDirectories collection (http://msdn.microsoft.com/en-us/library/54dwfbb7.aspx) in web.config, the class that is in the sub-directory will be built firstly, and then the class that is in the root of App_Code directory is built last. If so, we cannot access class Codefile5 from class Codefile1.

     

    I look forward to hearing from you.

     

    Thomas Sun
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.