0

I'm not sure why this isn't working, but, when I build my ASP.NET WebSite, I get the following error when the referenced namespace is in a different file than the referencing class. When the two classes are in the same file, everything builds fine.

Error 2 The type or namespace name 'someSpace' could not be found (are you missing a using directive or an assembly reference?) CaseEvaluationPanel.ascx.cs 26 3 ExaminerGradeSheet

Default.aspx.cs

namespace someSpace
{
    public class EmptyClass : System.Web.UI.Page
    {
        public int someInt;
    }
}

CaseEvaluationPanel.ascx.cs

public class referencingClass : System.Web.UI.UserControl
{
    public void someMethod()
    {
        someSpace.EmptyClass anEmptyClass = new someSpace.EmptyClass();

        int someInt = anEmptyClass.someInt;
    }
}
John Saunders
  • 160,644
  • 26
  • 247
  • 397
XyberICE
  • 525
  • 2
  • 7
  • 16
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Jan 04 '15 at 05:23
  • @Saunders, ok point taken. I won't do this in future posts. – XyberICE Jan 05 '15 at 15:11
  • @mason, this is an ASP.NET WebSite so I _guess_ the answer is no, each page is in a separate, automatically generated assembly. Is this the problem? If so, how can I "reference" another ASP.NET page assembly? – XyberICE Jan 05 '15 at 15:14

1 Answers1

0

You can change your code as shown below.

namespace someSpace
{
    public class EmptyClass : System.Web.UI.Page
    {
        public int someInt;
    }
}

namespace someSpace
{
     public class referencingClass : System.Web.UI.UserControl
     {
         public void someMethod()
         {
             EmptyClass anEmptyClass = new EmptyClass();

             int someInt = anEmptyClass.someInt;
         }
     }
}
Omer Harmansa
  • 29
  • 1
  • 5