Results 1 to 4 of 4

Thread: Compile class without VS Studio .Net

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    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.

  2. #2
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    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.

  4. #4
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609
    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
  •  



Click Here to Expand Forum to Full Width