Why this code don't work?

Discussion in 'ASP .Net' started by Wilson Beirigo Duarte, Apr 26, 2004.

  1. Hi,

    I'm a newbie in ASP.NET and try to run a code from www.asp.net, session
    tutorials subsession
    ASP.NET Web Forms topic Working With Business Objects




    ----------------------------------------------------------------------------
    ---------------------------------------
    webform1.aspx
    ----------------------------------------------------------------------------
    --------------------------------------

    <%@ Import Namespace="HelloWorld" %>
    <html>
    <style>
    div
    {
    font: 8pt verdana;
    background-color:cccccc;
    border-color:black;
    border-width:1;
    border-style:solid;
    padding:10,10,10,10;
    }
    </style>
    <script language="VB" runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    Dim Comp As HelloObjVB
    Comp = New HelloObjVB()
    Message.InnerHtml &= Comp.SayHello() + "<p>"
    Comp.FirstName = "Microsoft .NET Framework"
    Message.InnerHtml &= Comp.SayHello() + "<p>"
    Comp.FirstName = "ASP.NET"
    Message.InnerHtml &= Comp.SayHello() + "<p>"
    Comp.FirstName = "World!!!"
    Message.InnerHtml &= Comp.SayHello()
    End Sub
    </script>




    ----------------------------------------------------------------------------
    ------------------------------------
    HelloObj.vb
    ----------------------------------------------------------------------------
    -------------------------------------

    Imports System
    Imports System.Text

    Namespace HelloWorld
    Public Class HelloObj
    Private _name As String

    Public Sub New
    MyBase.New()
    _name = Nothing
    End Sub

    Public Property FirstName As String
    Get
    Return(_name)
    End get
    Set
    _name = value
    End Set
    End Property

    Public Function SayHello() As String
    Dim sb As New StringBuilder("Hello ")
    If (_name <> Nothing) Then
    sb.Append(_name)
    Else
    sb.Append("World")
    End If
    sb.Append("!")
    Return(sb.ToString())
    End Function
    End Class
    End Namespace



    ----------------------------------------------------------------------------
    -----------------------------------
    When I try to run the aplication occor the fowling error.
    ----------------------------------------------------------------------------
    ------------------------------------


    Server Error in '/WebApplication2' Application.
    ----------------------------------------------------------------------------
    ----

    Compilation Error
    Description: An error occurred during the compilation of a resource required
    to service this request. Please review the following specific error details
    and modify your source code appropriately.

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

    Source Error:


    Line 9: Sub Page_Load(Sender As Object, E As EventArgs)
    Line 10:
    Line 11: Dim Comp As HelloObjVB
    Line 12: Comp = New HelloObjVB()
    Line 13:


    Source File: http://localhost/WebApplication2/WebForm1.aspx Line: 11


    What is happing????
     
    Wilson Beirigo Duarte, Apr 26, 2004
    #1
    1. Advertising

  2. Wilson Beirigo Duarte

    John Smith Guest

    Hi,
    Any of the following could be the culprit.
    a. HelloObj.vb could be in an inaccessible directory (e.g. directory in at a
    higher level than the webapplication2 virtual directory or at a different
    structure altogether)
    b. It hasn't been first compiled into a .dll.
    c. It has been compiled but .dll was not referenced into your web project.

    Good luck,
    ..Js

    "Wilson Beirigo Duarte" <> wrote in message
    news:...
    > Hi,
    >
    > I'm a newbie in ASP.NET and try to run a code from www.asp.net,

    session
    > tutorials subsession
    > ASP.NET Web Forms topic Working With Business Objects
    >
    >
    >
    >
    > --------------------------------------------------------------------------

    --
    > ---------------------------------------
    > webform1.aspx
    > --------------------------------------------------------------------------

    --
    > --------------------------------------
    >
    > <%@ Import Namespace="HelloWorld" %>
    > <html>
    > <style>
    > div
    > {
    > font: 8pt verdana;
    > background-color:cccccc;
    > border-color:black;
    > border-width:1;
    > border-style:solid;
    > padding:10,10,10,10;
    > }
    > </style>
    > <script language="VB" runat="server">
    > Sub Page_Load(Sender As Object, E As EventArgs)
    > Dim Comp As HelloObjVB
    > Comp = New HelloObjVB()
    > Message.InnerHtml &= Comp.SayHello() + "<p>"
    > Comp.FirstName = "Microsoft .NET Framework"
    > Message.InnerHtml &= Comp.SayHello() + "<p>"
    > Comp.FirstName = "ASP.NET"
    > Message.InnerHtml &= Comp.SayHello() + "<p>"
    > Comp.FirstName = "World!!!"
    > Message.InnerHtml &= Comp.SayHello()
    > End Sub
    > </script>
    >
    >
    >
    >
    > --------------------------------------------------------------------------

    --
    > ------------------------------------
    > HelloObj.vb
    > --------------------------------------------------------------------------

    --
    > -------------------------------------
    >
    > Imports System
    > Imports System.Text
    >
    > Namespace HelloWorld
    > Public Class HelloObj
    > Private _name As String
    >
    > Public Sub New
    > MyBase.New()
    > _name = Nothing
    > End Sub
    >
    > Public Property FirstName As String
    > Get
    > Return(_name)
    > End get
    > Set
    > _name = value
    > End Set
    > End Property
    >
    > Public Function SayHello() As String
    > Dim sb As New StringBuilder("Hello ")
    > If (_name <> Nothing) Then
    > sb.Append(_name)
    > Else
    > sb.Append("World")
    > End If
    > sb.Append("!")
    > Return(sb.ToString())
    > End Function
    > End Class
    > End Namespace
    >
    >
    >
    > --------------------------------------------------------------------------

    --
    > -----------------------------------
    > When I try to run the aplication occor the fowling error.
    > --------------------------------------------------------------------------

    --
    > ------------------------------------
    >
    >
    > Server Error in '/WebApplication2' Application.
    > --------------------------------------------------------------------------

    --
    > ----
    >
    > Compilation Error
    > Description: An error occurred during the compilation of a resource

    required
    > to service this request. Please review the following specific error

    details
    > and modify your source code appropriately.
    >
    > Compiler Error Message: BC30002: Type 'HelloObjVB' is not defined.
    >
    > Source Error:
    >
    >
    > Line 9: Sub Page_Load(Sender As Object, E As EventArgs)
    > Line 10:
    > Line 11: Dim Comp As HelloObjVB
    > Line 12: Comp = New HelloObjVB()
    > Line 13:
    >
    >
    > Source File: http://localhost/WebApplication2/WebForm1.aspx Line: 11
    >
    >
    > What is happing????
    >
    >
    >
    >
     
    John Smith, Apr 26, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vaidas gudas

    Why Validator don't work

    vaidas gudas, Sep 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    459
    Kevin Spencer
    Sep 27, 2004
  2. Nicolas
    Replies:
    0
    Views:
    351
    Nicolas
    Jan 28, 2005
  3. Horace Nunley

    why why why does function not work

    Horace Nunley, Sep 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    461
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Sep 27, 2006
  4. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    908
    Mark Rae
    Dec 21, 2006
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,990
    Smokey Grindel
    Dec 2, 2006
Loading...

Share This Page