i have developed a very simple program using vs2010 as under and found exception like unable to connect to the remote server. i also tried to update the visual studio and reinstalled it but problem still exist.i tried to connect the visual studio by option online privacy statement under help menu but it even cant open google home page. i think there is a problem in visual studio in my pc or any port is closed or some thing else is going wrong.
Public Class Form1
Dim doc As HtmlDocument = New HtmlDocument
Dim a As HtmlDocument = New HtmlDocument
Dim web As HtmlWeb = New HtmlWeb
Private _loadURL As HtmlDocument
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
doc = web.Load("http://Dawn.com/") ' (connection exception occur at this point)
End Sub
End Class
I think your network connection is connected through the PROXY SERVER or behind the proxy server. So you've to configure proxy server settings first for accessing any website or internet resource. The code below may help you.
Dim o As New MyWebService.Name
Dim pr As New System.Net.WebProxy("100.0.1.1", 80)
pr.Credentials = System.Net.CredentialCache.DefaultCredentials
o.Proxy = pr
Dim ds As New DataSet
ds = o.GetMyData(Me.TextBox1.Text, "password")
Me.DataGridView1.DataSource = ds.Tables(0)
You've to modify it according to your proxy configuration. (you can see proxy server address in browser settings or options)
Related
I'm studying how the FTP protocall works in vb.net. The client side is more than well documented and very easy to follow, however I cant find anything on building an FTP server....Maybe there is no such thing as a virtual FTP server?
I did manage to find some document online which sends files back and forth but its not an actual FTP server (rather a clever way of mimicking one).
the client side code bellow clearly states FTPWebRequests and also clearly makes a connection to an FTP server ussing a password and username... its my probable understanding a means of creating a virtual FTP server also then exists?
Imports System.IO
Imports System.Net
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Create Request To Download File'
Dim wrDownload As FtpWebRequest = WebRequest.Create("ftp://ftp.test.com/file.txt")
'Specify That You Want To Download A File'
wrDownload.Method = WebRequestMethods.Ftp.DownloadFile
'Specify Username & Password'
wrDownload.Credentials = New NetworkCredential("user", "password")
'Response Object'
Dim rDownloadResponse As FtpWebResponse = wrDownload.GetResponse()
'Incoming File Stream'
Dim strFileStream As Stream = rDownloadResponse.GetResponseStream()
'Read File Stream Data'
Dim srFile As StreamReader = New StreamReader(strFileStream)
Console.WriteLine(srFile.ReadToEnd())
'Show Status Of Download'
Console.WriteLine("Download Complete, status {0}", rDownloadResponse.StatusDescription)
srFile.Close() 'Close
rDownloadResponse.Close()
End Sub
I have created an application in vb.net using sql server database and crystal reports, I then created the setup file using visual studio 2015 installer extension and installed the project on my Computer from which the application was developed and it is working fine. The issue starts when I install in the client computer, the application does not even start in the client machine, I have installed the .netFramework required and crystal reports run time engine in the client machine but still the app is not starting.
I have a background worker on my startup form and the connection is tested on form load. If the connection is successful the applications the creates a crystal report from a table in the database and if connection is not successful, the application loads the configuration form to manually configure the connection string and a message box will show the exception occurred.
Below is the code
Imports System.ComponentModel
Imports System.Data.SqlClient
Public Class loader
Dim connection As SqlConnection
Private Sub loader_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
If BackgroundWorker1.CancellationPending Then
e.Cancel = True
Else
ShowPanel([Panel2])
LoaderReportLoading([CrystalReportViewer1])
End If
End Sub
Delegate Sub LoadRpt(ByVal [crv] As Object)
Delegate Sub SetPanelVisible(ByVal [panel] As Panel)
Private Sub LoaderReportLoading(ByVal [crv] As Object) 'use the same delegate LoadRpt
Try
If My.Settings.connection = "" Then
server_configuration.ShowDialog()
Else
connection = New SqlConnection(My.Settings.connection)
connection.Open()
Dim CoTable As New DataTable
Using command As New SqlCommand("SELECT * FROM COMPANY", connection)
Dim adapter As New SqlDataAdapter(command)
adapter.Fill(CoTable)
End Using
Dim rep As New loaderReport
rep.Database.Tables("COMPANY").SetDataSource(CoTable)
If [crv].InvokeRequired Then
Dim myDelegate As New LoadRpt(AddressOf LoaderReportLoading)
Me.Invoke(myDelegate, New Object() {crv})
Else
[crv].ReportSource = rep
End If
connection.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "The following Error Occured While Connecting to the database")
server_configuration.ShowDialog()
End Try
End Sub
Private Sub ShowPanel(ByVal [panel] As Panel)
If [panel].InvokeRequired Then
Dim myDelegate As New SetPanelVisible(AddressOf ShowPanel)
Me.Invoke(myDelegate, New Object() {panel})
Else
[panel].Visible = True
End If
End Sub
End Class
I don't have any idea of using windows event logs, this is my first desktop application to be deployed.
Finally got the error after implementing logging on my system. The error was with the runtime engine for crystal reports. I changed a version of the crystal reports from SP30 to SP26 and all is working fine now.
I am using VB.NET and MySql and created a report, the report is working without any error on developer machine. It gives following error when I installed it and running on another machine. I have included Microsoft.ReportViewer.Common.dll, Microsoft.ReportViewer.WinForms.dll
This is my code for loading report
Private Sub frmRptCustomerBal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim cn As New dbConnection
cn.connect()
rptCustomerBalTableAdapter.Connection = cn.conn
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
ReportViewer1.LocalReport.ReportPath = "rptCustomerBal.rdlc"
Me.rptCustomerBalTableAdapter.Fill(Me.rptCustomerBal._rptCustomerBal)
Me.ReportViewer1.RefreshReport()
cn.close_conn()
End Sub
It looks like you haven't installed Report Viewer on the client system.
Here is the download link for Report Viewer.
How can I add my application to the exception list of windows firewall, using vb.net code?
Thanks
Windows Vista and 7 provide a rather robust firewall API that can be used to add exceptions to the firewall. The code below will add an exception to the windows firewall for the specified application, provided that the code is run with administrator privileges. Add a reference to %systemroot%\system32\FirewallAPI.dll to your application.
Imports NetFwTypeLib
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Create the Application we want to add to the exception list
Dim appType As Type = Type.GetTypeFromProgID("HnetCfg.FwAuthorizedApplication")
Dim app As INetFwAuthorizedApplication
app = DirectCast(Activator.CreateInstance(appType), INetFwAuthorizedApplication)
' Set the application properties
app.Name = "Negative0's Sandbox"
app.ProcessImageFileName = "C:\Users\Negative0\vbsandbox2.exe"
app.Enabled = True
' Get the firewall manager, so we can get the list of authorized apps
Dim fwMgrType As Type = Type.GetTypeFromProgID("HnetCfg.FwMgr")
Dim fwMgr As INetFwMgr
fwMgr = DirectCast(Activator.CreateInstance(fwMgrType), INetFwMgr)
' Get the list of authorized applications from the Firewall Manager, so we can add our app to that list
Dim apps As INetFwAuthorizedApplications
apps = fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications
apps.Add(app)
End Sub
Source
I'm working on a server/client TCP communication and it works fine, altough I can't make an application to add the software to the Windows firewall exception. I did found a sample, but it didn't worked.
My code:
Imports NetFwTypeLib
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim appType As Type = Type.GetTypeFromProgID("HnetCfg.FwAuthorizedApplication")
Dim app As INetFwAuthorizedApplication
app = DirectCast(Activator.CreateInstance(appType), INetFwAuthorizedApplication)
' Set the application properties
app.Name = "My App"
app.ProcessImageFileName = "c:\users\klein\documents\visual studio 2012\projects\tcp_server\tcp_server\bin\debug\tcp_server.exe"
app.Enabled = True
' Get the firewall manager, so we can get the list of authorized apps
Dim fwMgrType As Type = Type.GetTypeFromProgID("HnetCfg.FwMgr")
Dim fwMgr As INetFwMgr
fwMgr = DirectCast(Activator.CreateInstance(fwMgrType), INetFwMgr)
' Get the list of authorized applications from the Firewall Manager, so we can add our app to that list
Dim apps As INetFwAuthorizedApplications
apps = fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications
apps.Add(app)
End Sub
End Class
The code runs perfectly, no exception detected. Yet, the program is not listed after the form is loaded.
Thank you.
Look at this:
Programatically Add Exceptions to a Windows Firewall Using C#