PDA

Click to See Complete Forum and Search --> : Command-line Compiler (vbc.exe)


ljlevend
Apr 26th, 2002, 03:33 PM
I can't get the command-line compiler to work. I get the following error messages when I use the compiler on a blank Windows Form by typing "vbc.exe Form1.vb" from the Visual Studio .NET Command Prompt (i.e., C:\Program Files\Visual Studio .NET\Common7\Tools\vsvars32.bat):

vbc : error BC30420: 'Sub Main' was not found in 'Form1'.
c:\test01\Form1.vb(3) : error BC30002: Type 'System.Windows.Forms.Form' is not d
efined.

Inherits System.Windows.Forms.Form
~~~~~~~~~~~~~~~~~~~~~~~~~
c:\test01\Form1.vb(18) : error BC30284: sub 'Dispose' cannot be declared 'Overri
des' because it does not override a sub in a base class.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
~~~~~~~
c:\test01\Form1.vb(28) : error BC30002: Type 'System.ComponentModel.IContainer'
is not defined.

Private components As System.ComponentModel.IContainer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\test01\Form1.vb(34) : error BC30002: Type 'System.ComponentModel.Container' i
s not defined.

components = New System.ComponentModel.Container()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\test01\Form1.vb(35) : error BC30456: 'Text' is not a member of 'Form1'.

Me.Text = "Form1"
~~~~~~~


Obviously I'm doing something wrong. Can somebody please help? Also, my ultimate goal is to compile my program using ngen.exe so please let me know if using ngen is any different than vbc.

Thanks to anyone who can help. I've wasted more time than I'd like to admit on this problem. Lance

Thelonius
Apr 26th, 2002, 03:57 PM
Post the code for you form.

ljlevend
Apr 26th, 2002, 10:23 PM
The only code is the stuff that is automatically created when you start a new Windows Form project. Here it is:


Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.Text = "Form1"
End Sub

#End Region

End Class


Of course I have tried to add some code (Controls, simple Functions, Sub Main in a Class or a Module, etc.) but then I just get more error messages. Thanks.

Cander
Apr 30th, 2002, 09:52 AM
a) You need a Sub Main() with the code

Application.Run(New Form1)

b) you need to specify references into the compiler
/r:System.dll,system.windows.formsdll

ljlevend
Apr 30th, 2002, 10:35 PM
Thanks a lot Cander! Thanks to you I finally got it to work. Unfortunately, now I have even more questions:

1. Are there any good references that explain Command-line compiling? (please ignore the following if you have a reference)
2. Where did you learn about the requirement for the /r:System.dll,system.windows.forms.dll?
3. When I run the .exe file a MSDOS Box opens. What's up with that?
4. Is there a way to make it so that you don't have to specify references individually? I added a Button and suddenly I needed to include System.Drawing.dll. I imagine that this could get messy in a hurry.

Cander
May 1st, 2002, 08:29 AM
Originally posted by ljlevend
Thanks a lot Cander! Thanks to you I finally got it to work. Unfortunately, now I have even more questions:

1. Are there any good references that explain Command-line compiling? (please ignore the following if you have a reference)
2. Where did you learn about the requirement for the /r:System.dll,system.windows.forms.dll?
3. When I run the .exe file a MSDOS Box opens. What's up with that?
4. Is there a way to make it so that you don't have to specify references individually? I added a Button and suddenly I needed to include System.Drawing.dll. I imagine that this could get messy in a hurry.

1) I dont know of any good refernces but if you type vbc /? you can get the command list which is where I got my info. Most of it is pretty straightforward.

2) I just eventually picked it up somewhere from some example a while back. You can see the other System.something.dlls you may need if you look in the Microsoft .NET directory in your Windows directory. The dll's are all descriptivly named the same way their namespace is, so it is pretty easy to know which ones you would need to reference '/r:'

3) That is because by default, the compiler compiles to a console app, so the console box (DOS box) opens. To stop that you need to target the compiler to a winexe..Add this parameter

/t:winexe

4) System.Drawing is for the sizing and Location you probably setup for the button. There is nothing you can do but keep up with what references you use. non Visual Programmers have done this for years. It just takes getting used to when you are comfortable with VB6 doing the compiling and referencing for you. Best way to keep yourself from possibly retyping out a long command line over and over again is to just put it into a .bat file i your projects directory.

ljlevend
May 1st, 2002, 11:38 PM
Wow! Thanks for the wonderful reply. I really appreciate it.