Compiler Error Message:BC30002: Type 'MyClass' is not defined.

Posted on 2006-05-16
Last Modified: 2012-08-14
Compiler Error Message:BC30002: Type 'MyClass' is not defined.

I get The following Error Message: BC30002: Type 'MyClass' is not defined. Basically doesn't recognize my Class that i have made. i try to make the project as simple as possible to see if i can get around this problem but unfortunately i can't.
My project is made up of two simple files a web page called' DEFAULT.ASPX'  and a custom class called 'MyClass.vb'.
The aspx web page is made up of two components a grid and a button as shown underneath:

<asp:Button ID="Button1" runat="server" Text="Button"/>
<asp:DataGrid ID="Datagrid1" runat="server">

The code behind of the default.aspx page has the following syntax:

Imports MyClass

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myDAL  As MyClass= New MyClass
        Datagrid1.DataSource = myDAL.GetAllCustomersDAL

    End Sub
End Class

the  MyClass.vb file is located in the App_Data folder and  has the following syntax:

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb

Public Class MyClass
    Inherits System.Web.UI.Page
    Public DataBaseLocation As String = "C:\northwind.mdb"
    Public ConnString As String = "Provider=Microsoft.jet.oledb.4.0;Data Source=" + DataBaseLocation + ""

    Public Function GetAllCustomersDAL() As DataSet

        Dim Dataset1 As DataSet = New DataSet

        Dim SQLCommand As String
        Dim MyConnection As OleDbConnection = New OleDbConnection
        MyConnection.ConnectionString = ConnString
        SQLCommand = "SELECT * FROM customers"
        Dim dataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter(SQLCommand, MyConnection)
        dataAdapter1.Fill(Dataset1, "customers")

        Return Dataset1

    End Function
End Class

I also opened the VS 2005 command prompt and navigated to the appropriate folder and entered the following command:
vbc /r:System.dll,system.web.dll,microsoft.visualbasic.dll /t:library /out:MyClass.dll MyClass.vb
This creates the MyClass.dll in the same directory where the MyClass.vb is located (App_Code).
After this step i add reference to the file by going to Add References, this adds the 'MyClass.dll' file to the 'BIN' directory of the project. I would like to point out that the web application runs fine when i am in the VB.NET environment i.e (http://localhost:1563//myProject/default.aspx) but I get the ERROR when i run the web application off the web server on my computer i.e (  Any help is appreciated, i am very desperate since i have tried everything i know and i have had this problem for the past month now with no solution.
thanks in advance,
Question by:mmouzakitis
    LVL 33

    Expert Comment

    where is your MyClass.vb file located, App_Data or App_Code (You mentioned it being in both places), It needs to be in App_Code.

    You also don't need to use vbc with a web project, I'd get rid of any .dll's you may have created with this class in it.

    Author Comment

    The MyClass.vb is located in the  App_Code only not the App_Data. That was a typo error.   I have also tried running the web application without creating any dlls but without any luck!
    LVL 33

    Expert Comment

    Try taking away the "Imports MyClass" at the top of your aspx.vb file, I know you do not need this.

    Also, if this doesn't fix it, can you post the top few lines of your .aspx file (The ones that start with <%@...)

    Author Comment

    I took away the 'Imports MyClass' at the top of the aspx.vb file. it works in the VB.NET environment but doesn't work on my web server.
    The following code is from the aspx file:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    LVL 33

    Accepted Solution

    I'd clear everything out of your /bin folder, something is messed up beyond what you've given me here.  I see no reason why this should fail given what you've given me, unless you haven't set the main folder of the application as an application in IIS, and is looking at another app_code folder and ignoring the one you've made.  This is the only thing I could think that would make it work in VS 2005 but not at runtime.

    Author Comment

    THANKS A LOT that was the solution. i hadn't configured IIS properly  and specifically the 'application name' THANKS AGAIN

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now