Here is the form code for calling a ClickOnce windows application from VB.Net 2005:
Imports System.Deployment.Application
Imports System.Xml
Imports System.Configuration
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim blFailed As Boolean = False
Try
Dim strPath As String = “”
strPath = readINIfile(“AppPath”)
If strPath.Length > 0 Then
Try
System.Diagnostics.Process.Start(strPath)
Catch ex As Exception
blfailed = True
End Try
If blFailed Then
Try
strPath = “”
strPath = readINIfile(“AppPath2″)
If strPath.Length > 0 Then
System.Diagnostics.Process.Start(strPath)
End If
Catch ex As Exception
MessageBox.Show(“Unable to start application contact support” & vbCrLf & “Error: ” & ex.Message, “Error starting application”, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Me.Dispose()
End Sub
Private Function readINIfile(ByVal strSettingName As String) As String
‘Returns value from app.config file for passed setting name
readINIfile = ConfigurationManager.AppSettings(strSettingName)
End Function
End Class
Partial config file:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<appSettings>
<!–Application Name attribute set in application –>
<add key=”AppPath” value=”file://Server/App/Install/App.application” />
<add key=”AppPath2″ value=”http://Server/App/Install/App.application” />
</appSettings>
…
I installed this form using the setup wizard in VB.Net 2005. This allowed all users to have a desktop icon which they could use to launch the application. Let me know if you have any questions.





