Unable to compile asp.net code behind file using dos vbc command

I get compiler errors when I try to compile my vb code behind file using the
DOS command:
 
vbc /t:library /r:system.dll,system.web.dll  <filename.aspx.vb>

Most of the compiler errors were references to string functions such as Mid$,
Format$, Right$, Instr, etc not declared, and OLEDBError not found.

Below is a part of the compiler error messages:
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(5) : error BC30466: Namespace or type 'OleDbError' for the Imports 'System.Data.OleDb.OleDbError' cannot be found.

Imports System.Data.OleDb.OleDbError
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(6) : error BC30466: Namespace or type 'OleDbErrorCollection' for the Imports 'System.Data.OleDb.OleDbErrorCollection' cannot be found.

Imports System.Data.OleDb.OleDbErrorCollection
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(7) : error BC30466: Namespace or type 'OleDbException' for the Imports 'System.Data.OleDb.OleDbException' cannot be found.

Imports System.Data.OleDb.OleDbException
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(64) : error BC30451: Name 'Left' is not declared.

            CoverageCStr = Left(CoverageLimitStr, InStr(1, CoverageLimitStr, "_") - 1)
                           ~~~~                                                      
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(64) : error BC30451: Name 'InStr' is not declared.

            CoverageCStr = Left(CoverageLimitStr, InStr(1, CoverageLimitStr, "_") - 1)
                                                  ~~~~~                              
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(65) : error BC30451: Name 'Right' is not declared.

            CoverageDStr = Right(CoverageLimitStr, (Len(CoverageLimitStr) - InStr(1, CoverageLimitStr, "_")))
                           ~~~~~                                                                            
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(65) : error BC30451: Name 'Len' is not declared.

            CoverageDStr = Right(CoverageLimitStr, (Len(CoverageLimitStr) - InStr(1, CoverageLimitStr, "_")))
                                                    ~~~                                                     
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(65) : error BC30451: Name 'InStr' is not declared.

            CoverageDStr = Right(CoverageLimitStr, (Len(CoverageLimitStr) - InStr(1, CoverageLimitStr, "_")))
                                                                            ~~~~~                           
C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(83) : error BC30451: Name 'Format' is not declared.

                    PremiumTotalStr = Format$(CInt(PremiumTotalDbl), "###,###,##0")
                                      ~~~~~~~    




Answer this question

Unable to compile asp.net code behind file using dos vbc command

  • amandeep

    I compiled the code behind  as you suggested. The OLEDBError errors were fixed but  i am still getting the  errors for the string functions.

    any other suggestion

    thank you so much for your help. I really appreciate it.

    pete A


  • mepatuhoo

    By the way, if you wrote the code by hand using Notepad or a similar editor, check if you have the "Imports Microsoft .VisualBasic" statement. This could be the reason you still get the error even if you've referenced the VB dll.
  • MrHayes

    Try adding system.data.dll and microsoft.visualbasic.dll to your references parameter (/r). These references are automatically added when using VS, so it's a bit easy to forget adding them in when compiling via the commandline.


  • Rizak the Really Horrible

    Are you sure you included the microsoft.visualbasic.dll reference Your command-line should look like this:

    vbc /t:library /r:system.dll,system.web.dll,microsoft.visualbasic.dll,system.data.dll filename.aspx.vb

    This works fine for me if I compile a code-behind class with the string functions you used.

  • Jie Chen

    Hi!

    Thanks for asking!  I'm a member of the ASP.NET team, and was just popping over here to see what was going on.  The best place to ask ASP.NET questions is over on the ASP.NET forums at http://www.asp.net/welcome.aspx tabindex=1&tabid=39

    The short answer to your question is to use the ASPNET_Compilier.exe instead of the VB compilier, and that should help to make your life a lot easier.

    HTH,
    PEte



  • Soul

    Hi,

    thank you for your help.

    I did as you suggested. I added Imports Microsoft.VisualBasic statement to my
    class definition and recompile using the following command line:

    vbc /t:library /r:system.dll,system.web.dll,Microsoft.VisualBasic.dll,system.data.dll  <file.aspx.vb>

    This resolved the compiler errors for the string functions. However, the compiler still will not resolve errors below.

    What other reference should I include in my command line



    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(392) : error BC30451: Name 'TableCaptionAlign' is not declared.

                PremiumTable.CaptionAlign = TableCaptionAlign.Top
                                            ~~~~~~~~~~~~~~~~~   
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(393) : error BC30451: Name 'Color' is not declared.

                PremiumTable.BorderColor = Color.Navy
                                           ~~~~~    
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(395) : error BC30451: Name 'Color' is not declared.

                PremiumTable.ForeColor = Color.Navy
                                         ~~~~~    
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(402) : error BC30002: Type 'TableRow' is not defined.

                    Dim PremRow As New TableRow
                                       ~~~~~~~~
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(408) : error BC30451: Name 'Color' is not declared.

                        PremRow.BackColor = Color.Navy
                                            ~~~~~    
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(409) : error BC30451: Name 'Color' is not declared.

                        PremRow.ForeColor = Color.White
                                            ~~~~~     
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(415) : error BC30451: Name 'Color' is not declared.

                        PremRow.BackColor = Color.White
                                            ~~~~~     
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(416) : error BC30451: Name 'Color' is not declared.

                        PremRow.ForeColor = Color.Blue
                                            ~~~~~    
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(421) : error BC30002: Type 'TableCell' is not defined.

                        Dim PremCell As New TableCell
                                            ~~~~~~~~~
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(424) : error BC30451: Name 'HorizontalAlign' is not declared.

                            PremCell.HorizontalAlign = HorizontalAlign.Center
                                                       ~~~~~~~~~~~~~~~      
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(425) : error BC30451: Name 'VerticalAlign' is not declared.

                            PremCell.VerticalAlign = VerticalAlign.Bottom
                                                     ~~~~~~~~~~~~~      
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(426) : error BC30451: Name 'Color' is not declared.

                            PremCell.ForeColor = Color.White
                                                 ~~~~~     
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(432) : error BC30451: Name 'HorizontalAlign' is not declared.

                            PremCell.HorizontalAlign = HorizontalAlign.Right
                                                       ~~~~~~~~~~~~~~~     
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(433) : error BC30451: Name 'VerticalAlign' is not declared.

                            PremCell.VerticalAlign = VerticalAlign.Bottom
                                                     ~~~~~~~~~~~~~      
    C:\Inetpub\wwwroot\CEAProduction\CEAPremiumRenter.aspx.vb(434) : error BC30451: Name 'Color' is not declared.

                  


  • Unable to compile asp.net code behind file using dos vbc command