GUI not working

  • Thread starter Thread starter Hari
  • Start date Start date
H

Hari

I tried compiling the following source code:

Imports System
Imports System.Windows.Forms

Public Class Form1

Shared Sub Main
Dim f1 As New Form()
End Sub

End Class


I got the following errors:

error BC30466: Namespace or type 'Forms' for the Imports
'System.Windows.Forms' cannot be found.
Imports System.Windows.Forms
~~~~~~~~~~~~~~~~~~~~

error BC30002: Type 'Form' is not defined.
Dim f1 As New Form()
~~~~

I thought my entire stack of libraries was gone, but then when I tried to
compile the following code:

Imports System

Public Class Form1

Shared Sub Main
Console.WriteLine("Hello World")
End Sub

End Class


It compiled and ran perfectly. What have I done wrong? Do I need to change
the syntax of my code or download libraries? Is it that I am not compiling
my code correctly. Please reply soon. Thanks all- Hari.

P.S.
If you wish to reply to me personally (which I discourage), please remove
the x from my e-mail addresses as it only exists to prevent spam.
 
error BC30466: Namespace or type 'Forms' for the Imports
'System.Windows.Forms' cannot be found.
Imports System.Windows.Forms

Hmmm, check if you have a reference to System.Windows.Forms.

Maybe your default references are screwed up?
 
Hmmm, check if you have a reference to System.Windows.Forms.
Maybe your default references are screwed up?

When I type in:

vbc /r:System.Windows.Forms

I get 2 errors reading:

vbc : Command line error BC2017 : could not find library
'System.Windows.Forms'

vbc: Fatal error BC2000 : compiler initialization failed unexpectedly: The
system cannot find the file specified.


If this means that I do not have the libraries necessary to run a GUI
application, could someone please give me a link to where I can download the
SDK. I have already tried one download through MSDN, but it didn't seem to
work. Thanks all.
 
When I type in:

vbc /r:System.Windows.Forms

I get 2 errors reading:

vbc : Command line error BC2017 : could not find library
'System.Windows.Forms'

vbc: Fatal error BC2000 : compiler initialization failed unexpectedly: The
system cannot find the file specified.


If this means that I do not have the libraries necessary to run a GUI
application, could someone please give me a link to where I can download the
SDK. I have already tried one download through MSDN, but it didn't seem to
work. Thanks all.

vbc /r:System.Windows.Forms.dll

You have to add the .dll
 
Hari said:
When I type in:

vbc /r:System.Windows.Forms
------------------------^
here you need to specify the assembly name which is System.Windows.Forms.dll
and which contains the namespace System..Windows.Forms.
here's how you need to specify the command (seperate multiple assemblies
with a comma):
vbc /r:System.dll,System.Windows.Forms.dll test.vb
where test.vb might be something like:

Imports System
Imports System.Windows.Forms

Public Class Form1

Shared Sub Main
Dim f1 As New Form()
f1.Width = 300
f1.Height = 300
f1.ShowDialog()
End Sub

End Class

hope this helps..
Imran.
 
Hari said:
I tried compiling the following source code:

Imports System
Imports System.Windows.Forms

Public Class Form1

Shared Sub Main
Dim f1 As New Form()
End Sub

End Class


I got the following errors:

error BC30466: Namespace or type 'Forms' for the Imports
'System.Windows.Forms' cannot be found.
Imports System.Windows.Forms
~~~~~~~~~~~~~~~~~~~~

It sounds as though your project is a console application instead of a
Windows Forms application, and the reference to System.Windows.Forms.dll
never got added for you.

Best Regards,

Andy
 
Imports System
Imports System.Windows.Forms

Public Class Form1

Shared Sub Main
Dim f1 As New Form()
f1.Width = 300
f1.Height = 300
f1.ShowDialog()
End Sub

End Class

I typed in that exact code, except I called it Form2 and replaced Class
Form1 with Class Form2. Then I typed the following into the command prompt:

vbc /r:System.dll, System.Windows.Forms.dll Form2.vb

and got:

vbc /r:System.dll, System.Windows.Forms.dll Form2.vb
vbc : Command line error BC2001 : file 'System.Windows.Forms.dll' could not
be found

Now what?
 
It sounds as though your project is a console >application instead of a
Windows Forms application, and the reference to >System.Windows.Forms.dll
never got added for you.

If so, how do I get the System.Windows.Forms.dll to get added? I tried the
whole referencing thing, but I didn't seem to work. Thanks.
 
Hari,

That sounds kinda strange.
do you have that dll - System.Windows.Forms.dll - on your machine?
it should be under %Root%\WINNT\Microsoft.NET\Framework\v1.x.xxxx\ for
windows 2000
or under %Root%\Windows\Microsoft.NET\Framework\v1.x.xxxx\ for windows XP.
Infact, that is where vbc.exe is also located - for the default installation
atleast.

let me know..
Imran.
 
THANKS SO MUCH everyone!

I finally got the whole thing to work. First I took Imran's advice and went
looked for the vbc.exe. I found it in
C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322. Also in this directory I found
System.Windows.Forms.dll. I wondered why the whole thing wasn't working and
I typed in:

vbc /r:System.dll, System.Windows.Forms.dll Form2.vb

and got some errors. Then, I removed the space between the comma and
System.Windows..... so I got

vbc /r:System.dll,System.Windows.Forms.dll Form2.vb

AND IT WORKED. Thanks so much everyone, I really owe it all to you guys.
Once again thank you.
 
Back
Top