Link to home
Start Free TrialLog in
Avatar of mmouzakitis
mmouzakitis

asked on

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

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


I get The following Error Message: BC30002: Type 'MyClass' is not defined. Basically vb.net 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"/>
<br/>
<br/>
<asp:DataGrid ID="Datagrid1" runat="server">
</asp:DataGrid>

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

        datagrid1.databind()
    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 (http://www.wiredbrain123.com/default.aspx).  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,
 mike.
Avatar of raterus
raterus
Flag of United States of America image

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.
Avatar of mmouzakitis
mmouzakitis

ASKER

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!
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 <%@...)
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" %>
ASKER CERTIFIED SOLUTION
Avatar of raterus
raterus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
THANKS A LOT that was the solution. i hadn't configured IIS properly  and specifically the 'application name' THANKS AGAIN