0

I'm trying to add a class to a new namespace in my project. I have the following:

Namespace Admin
    Public Class Page
        ' Some Code
    End Class
End Namespace

I'm then trying to access that on my code behind file using:

Dim page As New Admin.Page()

For some reason, it isn't recognising Admin as a namespace, is there something obvious I'm missing here? I've attempted to add a reference to my namespace, but it does not appear in the list when I right click references and add reference in the solution explorer

6
  • VB appends NameSpaces you add. So if the Project root NS is WindowsApplication1, that one becomes, WindowsApplication1.Admin Commented Jan 19, 2015 at 21:27
  • Where are these files? Commented Jan 19, 2015 at 21:27
  • @Plutonix: Yes, but the consuming file would also be in that namespace. Commented Jan 19, 2015 at 21:27
  • I was addressing why the OP may not see an Admin in any list. But yes more info on the config would help Commented Jan 19, 2015 at 21:29
  • The class is in the following folder path: App_Code > Classes > Pages > Admin > Page.vb The file I'm trying to reference this in is a codebehind in the root folder. My project namespace is Bard, and I'm trying Bard.Admin, but that isn't working. Commented Jan 19, 2015 at 21:38

2 Answers 2

1

I'm not sure how many people will need this, but it turns out the issue is to do with the "Build Action" setting on the class file in VS2012. I needed to change it to Compile, as opposed to "Content".

I'm unsure what this does, I just know that this allowed me to access the namespace.

Sign up to request clarification or add additional context in comments.

1 Comment

0

The Answer is Simple, if you have specified the Root Namespace from the Project Properties > Applications, then you will need to call your namespace as

Dim page As New <Rootnamespace>.Admin.Page()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.