-1

I'm getting a compile error "Type 'commonClass' is not defined" in a file directly beneath the project (\\alf.aspx > alf.aspx.vb) on this line of code:

Dim pDAO As New commonClass

There is such a class, in \\App_Code\commonClass.vb:

Public Class commonClass

What is needed for "alf" to see "commonClass"?

This is probably a very basic (no pun intended) question, but I am a newbie to VB.

UPDATE

Does this have anything to do with the code in the legacy project "seeing" the other code, and the new one not: in the legacy project, the Visual Studio menu items are:

FILE
EDIT
VIEW
**WEBSITE**
BUILD
DEBUG
. . .

...whereas in the new project, they are:

FILE
EDIT
VIEW
**PROJECT**
BUILD
DEBUG
. . .

IOW, the new project (which I created using File > New Project > Templates > VB > New Project) has a "PROJECTS" menu item, whereas the legacy project has a "WEBSITE" menu item.

Will re-doing it as File > New Website > ... make the difference? Is there a way to change it to a website without going through that?

UPDATE 2

Both the legacy code, which compiles, and the new project, which doesn't, contain:

// alf.aspx.vb
Partial Class alf
    Inherits Page

-and:

// App_Code\commonClass.vb
Public Class commonClass

I see no "Namespace" in either file...

UPDATE 3

So, wondering if the fact that I created a new project rather than a new website is the crux of the problem, I tried creating a new website, but it tells me, "An item with the same key has already been added" and then the WebSite project - which I have not touched beyond creating it - starts off with 21 Errors and 13 Warnings

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

2 Answers2

2

You have two files. One for your asp.net file (alf.aspx.vb) and one for your commonClass (I assume commonClass.vb). Do both of these files have a Namespace defined and are they both the same Namespace (alf)? If they don't match then you will get the error you are describing.

Namespace alf
    Public Class commonClass
        Public Shared Sub Execute()
            Console.WriteLine("Blah")
        End Sub
    End Class
End Namespace
Rick S
  • 6,476
  • 5
  • 29
  • 43
0

I solved this wide-ranging and confounding issue with a three-pronged approach, which is detailed here.

Community
  • 1
  • 1
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862