|
-
Sep 23rd, 2003, 03:11 PM
#1
Thread Starter
Hyperactive Member
Compile class without VS Studio .Net
I have Visual Basic Standard Edition, which as far as I can tell, will not compile classes into a dll's (through the gui anyway). I know it can be accomplished using the VBC.exe and some command line arguments but I am not sure which arguments I should be using.
I thought this would work (a modified version of something I found on the Internet) but it doesn't.
vbc /t:library /r:System.dll class1.vb
It give me errors on every line. Is it because I don't have any Imports in the class? Is there a better way to do this?
By the way, this is how my class looks:
Code:
Public Class Class1
Function about() As String
Dim str1 As String = "About ClassLibrary1" & _
StrDup(2, vbCr) & _
"This is my story" & vbCr & _
"This is my song."
Return str1
End Function
End Class
Just in case you are wondering this is a sample from a learn VB.Net book.
Last edited by BukHix; Sep 23rd, 2003 at 03:25 PM.
-
Sep 24th, 2003, 02:15 AM
#2
Fanatic Member
Youre lucky I have had to manually compile modules for a little while and know how to do it 
What you do firstly is examine that the compiler is telling you, this is the initial output it gave:
Code:
C:\Documents and Settings\user>C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\vbc.exe /t:library /r:system.dll c:\temp.vb
Microsoft (R) Visual Basic .NET Compiler version 7.10.2292.4
for Microsoft (R) .NET Framework version 1.1.4322.510
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
c:\temp.vb(7) : error BC30451: Name 'StrDup' is not declared.
StrDup(2, vbCr) & _
~~~~~~
c:\temp.vb(7) : error BC30451: Name 'vbCr' is not declared.
StrDup(2, vbCr) & _
~~~~
c:\temp.vb(8) : error BC30451: Name 'vbCr' is not declared.
"This is my story" & vbCr & _
It was initially not able to access the StrDup() function. what you do then is go the the SDK, and search for the function reference, and at the bottom of the reference page it will tell you which DLL it is in in this case it was in the Microsoft.VisualBasic.DLL
Also, you'd want to specify where you want it to spit the DLL out to, cos I can never remember where it goes, in the MyDocuments or something 
Anyway, you should Import all your required namespaces as well as include the library in the compilation for it to work 
So add the following to the top of your code:
Code:
Imports System
Imports microsoft.visualbasic
and use the following to compile it (Make adjustmants for file locations):
Code:
C:\Documents and Settings\user>C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\vbc.exe /t:library /r:system.dll,microsoft.visualbasic.dll c:\temp.vb /out:c:\temp.dll
-
Sep 24th, 2003, 07:45 AM
#3
Thread Starter
Hyperactive Member
Very Cool. Thank you. I am going to use a variation of the command line you gave me in a batch file to streamline it some more. At some point I will try and make an app to automate it more. Thanks again.
-
Sep 24th, 2003, 08:46 AM
#4
Fanatic Member
At some stage I even had a batch file for going that in my quicklaunch bar 
But I would suggest against writing an app to help with this, its harder than you think , and not worth the trouble of you ask me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|