Ant
Ant

Reputation: 462

How do I add a class to a custom namespace?

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

Upvotes: 0

Views: 811

Answers (2)

Dennis Henry
Dennis Henry

Reputation: 74

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()

Upvotes: 0

Ant
Ant

Reputation: 462

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.

Upvotes: 1

Related Questions