calling class library from ASP.net

A

Alpesh Parmar

Hi Frens,
I've made a class library project in Visual Basic using
visual studio.net 2003. Now after i m done I copy the dll
from the \bin dir. of this project to my web application
project using ASP.net 's bin dir to use it.
and Then I am trying to use this dll in my .aspx page but
it gives me error message that object not defined. I
searched on internet for around 2 days but nothin worked
out.
So If anyone can solve my problem it'll eb gr8 help for me.

Thanks,
Alpesh Parmar
 
S

S. Justin Gengo

Alpesh,

You need to add a reference to the .dll in your project's references folder.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
A

Alpesh Parmar

Hi Justin,
I tried this way also. I put it in refrence library but whenever i m
trying to access class from that .dll file it gives me compiler error
saying

I m pasting the source code for the dll and the application too plzz
check it out and let me know.

This is Webform1.aspx file:

<%@ Page Language="VB"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="DOTNETMath" %>

<script runat="server" language="VB">
Sub Page_Load(sender As Object, evtArgs As EventArgs)
Dim MathComponent = New Operations()
Dim AddResult, SubResult As Single
AddResult = MathComponent.Add(CSng(FirstNum), CSng(SecondNum))
SubResult = MathComponent.Subs(CSng(FirstNum), CSng(SecondNum))
end sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

</form>

</body>
</html>
----------------------------------------------------------

this is DOTNETMath.dll file:

mports System
Imports Microsoft.VisualBasic

Namespace DOTNETMath
Public Class Operations

Public Sub New()
MyBase.New()
End Sub

Public Function Add(ByVal A As Single, ByVal B As Single) As
Single
Add = A + B
End Function

Public Function Subs(ByVal A As Single, ByVal B As Single) As
Single
Subs = A - B
End Function

Public Function Mul(ByVal A As Single, ByVal B As Single) As
Single
Mul = A * B
End Function

Public Function Div(ByVal A As Single, ByVal B As Single) As
Single
If B = 0 Then
Div = -1
Else
Div = A / B
End If
End Function

End Class
End Namespace
-----------------------------------------------------------
Plzz try to run this and let me know. I m waiting for ur answer and tell
me the exact procedure to do it.

Thanks,
Alpesh
 
S

S. Justin Gengo

Alphesh,

What does MyBase.New() in the components constructor refer to. This would
typically be used if you are inheriting another class into this component,
but I don't see an Inherits statement.

If this component is not inheriting from another you can safely remove the
entire constructor:

Public Sub New()
MyBase.New()
End Sub

since it doesn't do anything anyway.

I believe that the "Object is not defined" error is referring to the missing
MyBase.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top