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
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