vbc compile error

  • Thread starter Thread starter SomSallyX
  • Start date Start date
S

SomSallyX

Hi

I'm new to .Net; I tried a program to check for the internet connection. but
when i tried to compile the code i got the following error

error BC30002: Type 'WebResponse' is not defined.
error BC30002: Type 'WebRequest' is not defined.
(I compiled the program from command prompt using the switch /r and
specified the system.dll and system.Web.dll)

Any help is appreciated ...

Public Class Class1
Public Function IsConnectionAvailable() As Boolean
Dim objUrl As New System.Uri("http://www.google.com/")
Dim objWebReq As System.Net.WebRequest
objWebReq = System.Net.WebRequest.Create(objUrl)
Dim objResp As System.Net.WebResponse
Try
objResp = objWebReq.GetResponse
objResp.Close()
objWebReq = Nothing
Return True
Catch ex As Exception
objResp.Close()
objWebReq = Nothing
Return False
End Try
End Function

Public Shared Sub Main()
Dim objTest As New Class1()

If objTest.IsConnected() = True Then
System.Console.WriteLine("Connected")
else
System.Console.WriteLine("Not Connected")
End If

objTest = Nothing
End Sub

End Class
 
The System.Net.WebRequest is part of the System.dll assembly, so you code
should compile if you correctly have included a reference to this dll.


--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
* "SomSallyX said:
I'm new to .Net; I tried a program to check for the internet connection. but
when i tried to compile the code i got the following error

error BC30002: Type 'WebResponse' is not defined.
error BC30002: Type 'WebRequest' is not defined.
(I compiled the program from command prompt using the switch /r and
specified the system.dll and system.Web.dll)

The object browser tells me that the classes can be found in 'system.dll'.
 
Back
Top