|
 |
aspx thread: MyFile.vb to MyFile.dll
Message #1 by "McCloy, Russell" <Russell.McCloy@B...> on Fri, 12 Apr 2002 09:20:10 +1000
|
|
Hello all(Dan),
Can someone tell me the way to make a DLL from a class I have created in
VisualStudio.NET
I have a class called Tools.vb
============================================================================
=====================
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.SqlClient
Namespace myApp
Public Class tools : Inherits Page
Protected myDataGrid As DataGrid
Public runningTotal As Double = 0
Public liCount As Integer
Public Sub CalcTotal(ByVal _cost As String)
runningTotal += Double.Parse(_cost)
liCount += 1
End Sub 'calcTotals
Public Function MakeAUSDate(ByVal x As String) As String
MakeAUSDate = Day(x) & "/" & Month(x) & "/" & Year(x)
'MakeAUSDate = Month(x) & "/" & Day(x) & "/" & Year(x)
End Function
Public Function lsFixQuotes(ByVal sText As String) As String
lsFixQuotes = Replace(sText, "'", "''")
End Function
End Class
End Namespace
============================================================================
=====================
The code is irrelevant but I want to know how to make it, its own DLL that I
can use in other projects.
At present when I build my project all the code gets compiled into one big
DLL.
I used to do it with the vbc compiler in DOS but I really dont want to keep
using this.
Thanks for your help in advance.
RuSs
Message #2 by "Michael" <mlang@m...> on Fri, 12 Apr 2002 09:39:21 +1000
|
|
Select File->New->Project
Select Visual Basic Projects
Select Class Library
Give it the name of the dll you desire.
In the new class library solution:-
Right Mouse click on the solution root
Select Add->Add Existing Item
Browse to MyFile.vb
Select open
Select Build
Check the bin directory under your project you should find your dll
-----Original Message-----
From: McCloy, Russell [mailto:Russell.McCloy@B...]
Sent: Friday, 12 April 2002 9:20 AM
To: ASP+
Subject: [aspx] MyFile.vb to MyFile.dll
Hello all(Dan),
Can someone tell me the way to make a DLL from a class I have created in
VisualStudio.NET
I have a class called Tools.vb
============================================================================
=====================
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.SqlClient
Namespace myApp
Public Class tools : Inherits Page
Protected myDataGrid As DataGrid
Public runningTotal As Double = 0
Public liCount As Integer
Public Sub CalcTotal(ByVal _cost As String)
runningTotal += Double.Parse(_cost)
liCount += 1
End Sub 'calcTotals
Public Function MakeAUSDate(ByVal x As String) As String
MakeAUSDate = Day(x) & "/" & Month(x) & "/" & Year(x)
'MakeAUSDate = Month(x) & "/" & Day(x) & "/" & Year(x)
End Function
Public Function lsFixQuotes(ByVal sText As String) As String
lsFixQuotes = Replace(sText, "'", "''")
End Function
End Class
End Namespace
============================================================================
=====================
The code is irrelevant but I want to know how to make it, its own DLL that I
can use in other projects.
At present when I build my project all the code gets compiled into one big
DLL.
I used to do it with the vbc compiler in DOS but I really dont want to keep
using this.
Thanks for your help in advance.
RuSs
Message #3 by "McCloy, Russell" <Russell.McCloy@B...> on Fri, 12 Apr 2002 09:44:18 +1000
|
|
Thanks Michael for your quick reply.
I will try soon.
RuSs
-----Original Message-----
From: Michael [mailto:mlang@m...]
Sent: Friday, 12 April 2002 9:39 AM
To: ASP+
Subject: [aspx] RE: MyFile.vb to MyFile.dll
Select File->New->Project
Select Visual Basic Projects
Select Class Library
Give it the name of the dll you desire.
In the new class library solution:-
Right Mouse click on the solution root
Select Add->Add Existing Item
Browse to MyFile.vb
Select open
Select Build
Check the bin directory under your project you should find your dll
-----Original Message-----
From: McCloy, Russell [mailto:Russell.McCloy@B...]
Sent: Friday, 12 April 2002 9:20 AM
To: ASP+
Subject: [aspx] MyFile.vb to MyFile.dll
Hello all(Dan),
Can someone tell me the way to make a DLL from a class I have created in
VisualStudio.NET
I have a class called Tools.vb
============================================================================
=====================
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.SqlClient
Namespace myApp
Public Class tools : Inherits Page
Protected myDataGrid As DataGrid
Public runningTotal As Double = 0
Public liCount As Integer
Public Sub CalcTotal(ByVal _cost As String)
runningTotal += Double.Parse(_cost)
liCount += 1
End Sub 'calcTotals
Public Function MakeAUSDate(ByVal x As String) As String
MakeAUSDate = Day(x) & "/" & Month(x) & "/" & Year(x)
'MakeAUSDate = Month(x) & "/" & Day(x) & "/" & Year(x)
End Function
Public Function lsFixQuotes(ByVal sText As String) As String
lsFixQuotes = Replace(sText, "'", "''")
End Function
End Class
End Namespace
============================================================================
=====================
The code is irrelevant but I want to know how to make it, its own DLL that I
can use in other projects.
At present when I build my project all the code gets compiled into one big
DLL.
I used to do it with the vbc compiler in DOS but I really dont want to keep
using this.
Thanks for your help in advance.
RuSs
Message #4 by "McCloy, Russell" <Russell.McCloy@B...> on Tue, 23 Apr 2002 10:14:29 +1000
|
|
Hi Michael,
I finally got around to trying this.
I followed your steps and it built a DLL but The DLL is a compilation of my
whole solution and
not just of my component.
Say I have a component called:
tools.dll
I want to begin a new ASP.NET project.
I:
Right Mouse click on the solution root
Select Add->Add Existing Item
Browse to MyFile.vb
Select open
I then select:
Build
Build Solution
And it builds a DLL that is named in accordance with my new project name and
not Tools.DLL.
Any suggestions?
thanks
RuSs
-----Original Message-----
From: Michael [mailto:mlang@m...]
Sent: Friday, 12 April 2002 9:39 AM
To: ASP+
Subject: [aspx] RE: MyFile.vb to MyFile.dll
Select File->New->Project
Select Visual Basic Projects
Select Class Library
Give it the name of the dll you desire.
In the new class library solution:-
Right Mouse click on the solution root
Select Add->Add Existing Item
Browse to MyFile.vb
Select open
Select Build
Check the bin directory under your project you should find your dll
-----Original Message-----
From: McCloy, Russell [mailto:Russell.McCloy@B...]
Sent: Friday, 12 April 2002 9:20 AM
To: ASP+
Subject: [aspx] MyFile.vb to MyFile.dll
Hello all(Dan),
Can someone tell me the way to make a DLL from a class I have created in
VisualStudio.NET
I have a class called Tools.vb
============================================================================
=====================
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.SqlClient
Namespace myApp
Public Class tools : Inherits Page
Protected myDataGrid As DataGrid
Public runningTotal As Double = 0
Public liCount As Integer
Public Sub CalcTotal(ByVal _cost As String)
runningTotal += Double.Parse(_cost)
liCount += 1
End Sub 'calcTotals
Public Function MakeAUSDate(ByVal x As String) As String
MakeAUSDate = Day(x) & "/" & Month(x) & "/" & Year(x)
'MakeAUSDate = Month(x) & "/" & Day(x) & "/" & Year(x)
End Function
Public Function lsFixQuotes(ByVal sText As String) As String
lsFixQuotes = Replace(sText, "'", "''")
End Function
End Class
End Namespace
============================================================================
=====================
The code is irrelevant but I want to know how to make it, its own DLL that I
can use in other projects.
At present when I build my project all the code gets compiled into one big
DLL.
I used to do it with the vbc compiler in DOS but I really dont want to keep
using this.
Thanks for your help in advance.
RuSs
Message #5 by "Michael" <mlang@m...> on Tue, 23 Apr 2002 10:57:08 +1000
|
|
In the class library project it will build all the files in the project into
the DLL.
To use that dll in an ASP.NET Web Application (or any other managed project
type), create a new solution for your ASP.NET Web Application, right mouse
button click on References select "Add Reference", select Browse and
navigate to your class library's bin directory and select your tools.dll.
In your ASP.NET Web application you should then be able to access your class
library through it's root namespace. In C# the root namespace is visible in
the code inside the class library in VB I think you need to select
properties on the root of your class library solution. Once you know your
namespace you should be able to access it the same way you access system
namespace classes eg if your class library's namespace is MyTools and MyFile
contains the class "MyClass":-
Dim myObject as MyTools.MyClass;
-----Original Message-----
From: McCloy, Russell [mailto:Russell.McCloy@B...]
Sent: Tuesday, 23 April 2002 10:14 AM
To: ASP+; mlang@m...
Subject: RE: [aspx] RE: MyFile.vb to MyFile.dll
Hi Michael,
I finally got around to trying this.
I followed your steps and it built a DLL but The DLL is a compilation of my
whole solution and
not just of my component.
Say I have a component called:
tools.dll
I want to begin a new ASP.NET project.
I:
Right Mouse click on the solution root
Select Add->Add Existing Item
Browse to MyFile.vb
Select open
I then select:
Build
Build Solution
And it builds a DLL that is named in accordance with my new project name and
not Tools.DLL.
Any suggestions?
thanks
RuSs
-----Original Message-----
From: Michael [mailto:mlang@m...]
Sent: Friday, 12 April 2002 9:39 AM
To: ASP+
Subject: [aspx] RE: MyFile.vb to MyFile.dll
Select File->New->Project
Select Visual Basic Projects
Select Class Library
Give it the name of the dll you desire.
In the new class library solution:-
Right Mouse click on the solution root
Select Add->Add Existing Item
Browse to MyFile.vb
Select open
Select Build
Check the bin directory under your project you should find your dll
-----Original Message-----
From: McCloy, Russell [mailto:Russell.McCloy@B...]
Sent: Friday, 12 April 2002 9:20 AM
To: ASP+
Subject: [aspx] MyFile.vb to MyFile.dll
Hello all(Dan),
Can someone tell me the way to make a DLL from a class I have created in
VisualStudio.NET
I have a class called Tools.vb
============================================================================
=====================
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Data
Imports System.Data.SqlClient
Namespace myApp
Public Class tools : Inherits Page
Protected myDataGrid As DataGrid
Public runningTotal As Double = 0
Public liCount As Integer
Public Sub CalcTotal(ByVal _cost As String)
runningTotal += Double.Parse(_cost)
liCount += 1
End Sub 'calcTotals
Public Function MakeAUSDate(ByVal x As String) As String
MakeAUSDate = Day(x) & "/" & Month(x) & "/" & Year(x)
'MakeAUSDate = Month(x) & "/" & Day(x) & "/" & Year(x)
End Function
Public Function lsFixQuotes(ByVal sText As String) As String
lsFixQuotes = Replace(sText, "'", "''")
End Function
End Class
End Namespace
============================================================================
=====================
The code is irrelevant but I want to know how to make it, its own DLL that I
can use in other projects.
At present when I build my project all the code gets compiled into one big
DLL.
I used to do it with the vbc compiler in DOS but I really dont want to keep
using this.
Thanks for your help in advance.
RuSs
Message #6 by "J Donahue" <jdonahue@f...> on Tue, 23 Apr 2002 18:25:26
|
|
Michael -
I was reading with great interest your comments on creating a dll. I
followed your steps and created a DLL and included it in the references
for a project I am working on. The DLL simply has a function "userfunc"
that returns a boolean.
At the top of my project file, I included a "Imports
myFunctions.myFuncs.myClass1". In my code, I used "userfunc" in an
If/Then statement and received the following error "Reference to a non-
shared member requires an object reference.".
I then re-read your comments and included the line "Dim userfunc as
myFunctions.myFuncs.myClass1" and recompiled but I got the error "
Class 'myFunctions.myFuncs.myClass1' cannot be indexed because it has no
default property."
Can you please tell me what I'm doing wrong?
Thanks for your help!!! And...your comments were well written and easy
to understand....I appreciate that!!!
Message #7 by "Goh Mingkun" <mangokun@h...> on Wed, 24 Apr 2002 08:30:32
|
|
Here are the steps to access your DLL's functions after you have added a
Reference to it in your project:
Create an instance of the Class
1. Dim myClass As New classnamespace.classname
(classnamespace will be the same as the name of your DLL, unless you
have specified a different one in your Class Library's Project Properties.
(classname is the name of your Class file in your project, of course.)
Access its members
2. Dim str As String = myClass.GetHelloWorldAgain
Note: You dun have to import any namespaces to use a Class/DLL in a client
application. The neccessary namespace(s) should be already specified in
the Class/DLL itself.
Message #8 by "Goh Mingkun" <mangokun@h...> on Wed, 24 Apr 2002 08:50:01
|
|
In Russell's scenario, follow the steps below to build a DLL, and access
it in a client app.
Building Tools.dll
1. Create a new Visual Basic project, select Class Library.
For name: enter 'Tools'. (if you want your complied DLL to be Tools.dll)
(You can still change it in Project Properties, if you want)
2. Delete Class1.vb which is created automatically in every Class Library
project.
3. In Solution Explorer, right-click on the project node -> Add -> Add
Existing Item...
Browse to and select your Tools.vb, click OK.
Under your project, open Tools.vb and make sure you remove the
following lines:
......
Namespace myApp
......
End Namespace
4. Build this Class Library project.
Using Tools.dll in a client application (or even a Web Service)
1. Add a Reference to Tools.vb (found under the bin directory of the Class
Library project you built just now) in your project.
Create an instance of Class Tools in Tools.dll
2. At the top of your client code (outside any functions), type:
Dim ClsTools As New Tools.Tools
3. Then you can use any of its functions anywhere you want.
e.g.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Label1.Text = ClsTools.lsFixQuotes(TextBox1.Text)
End Sub
Note: You have have to import any namespaces in your client code.
Message #9 by "Goh Mingkun" <mangokun@h...> on Wed, 24 Apr 2002 08:53:29
|
|
Sorry, I typed wrongly in my previous message (Message 8 (#168556) by "Goh
Mingkun")
This line
> Note: You have have to import any namespaces in your client code.
should be been
Note: You DO NOT have to import any namespaces in your client code.
Message #10 by "J Donahue" <jdonahue@f...> on Wed, 24 Apr 2002 16:24:20
|
|
Thanks Goh!!!! It worked perfectly.
> Sorry, I typed wrongly in my previous message (Message 8 (#168556)
by "Goh
M> ingkun")
> This line
>> Note: You have have to import any namespaces in your client code.
> should be been
N> ote: You DO NOT have to import any namespaces in your client code.
|
|
 |